ZQuest Classic Coverage Report


Directory: src/
File: src/base/qst.cpp
Date: 2025-10-20 05:13:23
Exec Total Coverage
Lines: 9605 13248 72.5%
Functions: 114 143 79.7%
Branches: 7313 12369 59.1%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/flags.h"
3 #include "base/general.h"
4 #include "base/util.h"
5 #include "base/version.h"
6 #include "base/zapp.h"
7 #include "base/qrs.h"
8 #include "base/cpool.h"
9 #include "base/autocombo.h"
10 #include "base/packfile.h"
11 #include "base/dmap.h"
12 #include "base/combo.h"
13 #include "base/msgstr.h"
14 #include "base/flags.h"
15 #include <bit>
16 #include <filesystem>
17 #include <memory>
18 #include <optional>
19 #include <stdio.h>
20 #include <cstring>
21 #include <string>
22 #include <map>
23 #include <vector>
24 #include <assert.h>
25 #include <fmt/format.h>
26
27
28 #include "fmt/core.h"
29 #include "base/zc_alleg.h"
30 #include "base/zdefs.h"
31 #include "base/colors.h"
32 #include "tiles.h"
33 #include "base/zsys.h"
34 #include "base/qst.h"
35 #include "defdata.h"
36 #include "subscr.h"
37 #include "sfx.h"
38 #include "base/md5.h"
39 #include "zc/replay.h"
40 #include "zc/zelda.h"
41 #include "zinfo.h"
42 #include "zc/ffscript.h"
43 #include "particles.h"
44 #include "dialog/alert.h"
45 #include "base/misctypes.h"
46 #include "base/initdata.h"
47
48 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
49 extern void setZScriptVersion(int32_t s_version);
50
51 static bool read_ext_zinfo = false, read_zinfo = false;
52 static bool loadquest_report = false;
53 static char const* loading_qst_name = NULL;
54 static std::string last_loaded_qstpath;
55 static byte loading_qst_num = 0;
56 static byte subscr_mode = ssdtMAX;
57 // Very old quests only used a byte for combos, and each screen had a "combo page" to vary
58 // what combos were used. This vector just lets us convert those old quests on load.
59 static std::vector<byte> old_combo_pages;
60
61 dword loading_tileset_flags = 0;
62
63 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0},combo_auto_listpos[MAX_COMBO_COLS]={0};
64 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
65
66 #ifdef _MSC_VER
67 #define strncasecmp _strnicmp
68 #endif
69
70 #ifndef _AL_MALLOC
71 #define _AL_MALLOC(a) _al_malloc(a)
72 #define _AL_FREE(a) _al_free(a)
73 #endif
74
75 using std::string;
76 using std::pair;
77
78 extern int32_t hero_animation_speed; //lower is faster animation
79 extern byte *colordata;
80 extern tiledata *newtilebuf;
81 extern byte *trashbuf;
82 extern itemdata *itemsbuf;
83 extern wpndata *wpnsbuf;
84 extern comboclass *combo_class_buf;
85 extern guydata *guysbuf;
86 extern ZCHEATS zcheats;
87 extern char palnames[MAXLEVELS][17];
88 extern char *byte_conversion(int32_t number, int32_t format);
89 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
90 string zScript;
91 437 std::map<int32_t, script_slot_data > ffcmap;
92 437 std::map<int32_t, script_slot_data > globalmap;
93 437 std::map<int32_t, script_slot_data > genericmap;
94 437 std::map<int32_t, script_slot_data > itemmap;
95 437 std::map<int32_t, script_slot_data > npcmap;
96 437 std::map<int32_t, script_slot_data > ewpnmap;
97 437 std::map<int32_t, script_slot_data > lwpnmap;
98 437 std::map<int32_t, script_slot_data > playermap;
99 437 std::map<int32_t, script_slot_data > dmapmap;
100 437 std::map<int32_t, script_slot_data > screenmap;
101 437 std::map<int32_t, script_slot_data > itemspritemap;
102 437 std::map<int32_t, script_slot_data > comboscriptmap;
103 437 std::map<int32_t, script_slot_data > subscreenmap;
104 void free_newtilebuf();
105 bool combosread=false;
106 bool mapsread=false;
107 bool fixffcs=false;
108 bool fixpolsvoice=false;
109
110 // Each section had a separate, secondary versioning number, but it was never really utilized for
111 // its intended purpose so it's been removed. But we still write something in this field.
112 232 bool write_deprecated_section_cversion(word section_version, PACKFILE* f)
113 {
114 232 return p_iputw(section_version, f);
115 }
116
117 14898 bool read_deprecated_section_cversion(PACKFILE* f)
118 {
119 word unused;
120 14898 return p_igetw(&unused, f);
121 }
122
123 22006 void script_slot_data::update()
124 {
125
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 21999 times.
22006 switch (format)
126 {
127 case SCRIPT_FORMAT_INVALID:
128 7 output = fmt::format("{} --{}", slotname, scriptname);
129 7 break;
130 21999 case SCRIPT_FORMAT_DEFAULT:
131 default:
132 21999 output = fmt::format("{} {}", slotname, scriptname);
133 21999 }
134 22006 }
135
136 char qstdat_string[2048] = { 0 };
137
138 static zinfo* load_tmp_zi = NULL;
139
140 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
141 const byte clavio[9]={97,109,111,110,103,117,115,0};
142
143 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
144 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
145
146 const char *qst_error[] =
147 {
148 "OK","File not found","Invalid quest file",
149 "Version not supported","Obsolete version",
150 "Missing new data" , /* but let it pass in ZQuest */
151 "Internal error occurred", "Invalid password",
152 "Quest title doesn't match saved game", "Save file is for older version of quest; please start new save",
153 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
154 };
155
156 //for legacy quests -DD
157 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
158 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
159 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
160 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
161 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
162 };
163
164 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
165
166
167 char *byte_conversion(int32_t number, int32_t format)
168 {
169 static char num_str[40];
170
171 if(format==-1) //auto
172 {
173 format=1; //bytes
174
175 if(number>1024)
176 {
177 format=2; //kilobytes
178 }
179
180 if(number>1024*1024)
181 {
182 format=3; //megabytes
183 }
184
185 if(number>1024*1024*1024)
186 {
187 format=4; //gigabytes (dude, what are you doing?)
188 }
189 }
190
191 switch(format)
192 {
193 case 1: //bytes
194 sprintf(num_str,"%db",number);
195 break;
196
197 case 2: //kilobytes
198 sprintf(num_str,"%.2fk",float(number)/1024);
199 break;
200
201 case 3: //megabytes
202 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
203 break;
204
205 case 4: //gigabytes
206 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
207 break;
208
209 default:
210 abort();
211 break;
212 }
213
214 return num_str;
215 }
216
217 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
218 {
219 static char num_str1[40];
220 static char num_str2[40];
221 static char num_str[80];
222
223 if(format1==-1) //auto
224 {
225 format1=1; //bytes
226
227 if(number1>1024)
228 {
229 format1=2; //kilobytes
230 }
231
232 if(number1>1024*1024)
233 {
234 format1=3; //megabytes
235 }
236
237 if(number1>1024*1024*1024)
238 {
239 format1=4; //gigabytes (dude, what are you doing?)
240 }
241 }
242
243 if(format2==-1) //auto
244 {
245 format2=1; //bytes
246
247 if(number2>1024)
248 {
249 format2=2; //kilobytes
250 }
251
252 if(number2>1024*1024)
253 {
254 format2=3; //megabytes
255 }
256
257 if(number2>1024*1024*1024)
258 {
259 format2=4; //gigabytes (dude, what are you doing?)
260 }
261 }
262
263 switch(format1)
264 {
265 case 1: //bytes
266 sprintf(num_str1,"%db",number1);
267 break;
268
269 case 2: //kilobytes
270 sprintf(num_str1,"%.2fk",float(number1)/1024);
271 break;
272
273 case 3: //megabytes
274 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
275 break;
276
277 case 4: //gigabytes
278 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
279 break;
280
281 default:
282 abort();
283 break;
284 }
285
286 switch(format2)
287 {
288 case 1: //bytes
289 sprintf(num_str2,"%db",number2);
290 break;
291
292 case 2: //kilobytes
293 sprintf(num_str2,"%.2fk",float(number2)/1024);
294 break;
295
296 case 3: //megabytes
297 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
298 break;
299
300 case 4: //gigabytes
301 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
302 break;
303
304 default:
305 abort();
306 break;
307 }
308
309 sprintf(num_str, "%s/%s", num_str1, num_str2);
310 return num_str;
311 }
312
313 char *ordinal(int32_t num)
314 {
315 static const char *ending[4] = {"st","nd","rd","th"};
316 static char ord_str[8];
317
318 char *end;
319 int32_t t=(num%100)/10;
320 int32_t n=num%10;
321
322 if(n>=1 && n<4 && t!=1)
323 end = (char *)ending[n-1];
324 else
325 end = (char *)ending[3];
326
327 sprintf(ord_str,"%d%s",num%10000,end);
328 return ord_str;
329 }
330
331 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
332 {
333 int32_t ret;
334 *version=0;
335 *build=0;
336 byte temp_map_count=map_count;
337 byte temp_midi_flags[MIDIFLAGS_SIZE];
338 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
339
340 zquestheader tempheader{};
341
342 if(!f)
343 {
344 return qe_invalid;
345 }
346
347 ret=readheader(f, &tempheader);
348
349 if(ret)
350 {
351 return ret;
352 }
353
354 map_count=temp_map_count;
355 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
356 *version=tempheader.zelda_version;
357 *build=tempheader.build;
358 return 0;
359 }
360
361
362 bool find_section(PACKFILE *f, int32_t section_id_requested)
363 {
364
365 if(!f)
366 {
367 return false;
368 }
369
370 int32_t section_id_read;
371 bool catchup=false;
372 word dummy;
373 byte tempbyte;
374 char tempbuf[65536];
375
376
377 switch(section_id_requested)
378 {
379 case ID_RULES:
380 case ID_STRINGS:
381 case ID_MISC:
382 case ID_TILES:
383 case ID_COMBOS:
384 case ID_CSETS:
385 case ID_MAPS:
386 case ID_DMAPS:
387 case ID_DOORS:
388 case ID_ITEMS:
389 case ID_WEAPONS:
390 case ID_COLORS:
391 case ID_ICONS:
392 case ID_INITDATA:
393 case ID_GUYS:
394 case ID_MIDIS:
395 case ID_CHEATS:
396 break;
397
398 default:
399 al_trace("Bad section requested!\n");
400 return false;
401 break;
402 }
403
404 dword section_size;
405
406 //section id
407 if(!p_mgetl(&section_id_read,f))
408 {
409 return false;
410 }
411
412 while(!pack_feof(f))
413 {
414 switch(section_id_read)
415 {
416 case ID_RULES:
417 case ID_STRINGS:
418 case ID_MISC:
419 case ID_TILES:
420 case ID_COMBOS:
421 case ID_CSETS:
422 case ID_MAPS:
423 case ID_DMAPS:
424 case ID_DOORS:
425 case ID_ITEMS:
426 case ID_WEAPONS:
427 case ID_COLORS:
428 case ID_ICONS:
429 case ID_INITDATA:
430 case ID_GUYS:
431 case ID_MIDIS:
432 case ID_CHEATS:
433 catchup=false;
434 break;
435
436 default:
437 break;
438 }
439
440
441 while(catchup)
442 {
443 //section id
444 section_id_read=(section_id_read<<8);
445
446 if(!p_getc(&tempbyte,f))
447 {
448 return false;
449 }
450
451 section_id_read+=tempbyte;
452 }
453
454 if(section_id_read==section_id_requested)
455 {
456 return true;
457 }
458 else
459 {
460 //section version info
461 if(!p_igetw(&dummy,f))
462 {
463 return false;
464 }
465
466 if(!p_igetw(&dummy,f))
467 {
468 return false;
469 }
470
471 //section size
472 if(!p_igetl(&section_size,f))
473 {
474 return false;
475 }
476
477 //pack_fseek(f, section_size);
478 while(section_size>65535)
479 {
480 pfread(tempbuf,65535,f);
481 tempbuf[65535]=0;
482 section_size-=65535;
483 }
484
485 if(section_size>0)
486 {
487 pfread(tempbuf,section_size,f);
488 tempbuf[section_size]=0;
489 }
490 }
491
492 //section id
493 if(!p_mgetl(&section_id_read,f))
494 {
495 return false;
496 }
497 }
498
499 return false;
500 }
501
502
503
504
505
506 bool valid_zqt(PACKFILE *f)
507 {
508
509 //word tiles_used;
510 //word combos_used;
511 //open the file
512 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
513 if(!f)
514 return false;
515
516 //for now, everything else is valid
517 return true;
518
519 /*int16_t version;
520 byte build;
521
522 //read the version and make sure it worked
523 if(!p_igetw(&version,f))
524 {
525 goto error;
526 }
527
528 //read the build and make sure it worked
529 if(!p_getc(&build,f))
530 goto error;
531
532 //read the tile info and make sure it worked
533 if(!p_igetw(&tiles_used,f))
534 {
535 goto error;
536 }
537
538 for (int32_t i=0; i<tiles_used; i++)
539 {
540 if(!pfread(trashbuf,tilesize(tf4Bit),f))
541 {
542 goto error;
543 }
544 }
545
546 //read the combo info and make sure it worked
547 if(!p_igetw(&combos_used,f))
548 {
549 goto error;
550 }
551 for (int32_t i=0; i<combos_used; i++)
552 {
553 if(!pfread(trashbuf,sizeof(newcombo),f))
554 {
555 goto error;
556 }
557 }
558
559 //read the palette info and make sure it worked
560 for (int32_t i=0; i<48; i++)
561 {
562 if(!pfread(trashbuf,newpdTOTAL,f))
563 {
564 goto error;
565 }
566 }
567 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
568 {
569 goto error;
570 }
571 for (int32_t i=0; i<MAXLEVELS; i++)
572 {
573 if(!pfread(trashbuf,PALNAMESIZE,f))
574 {
575 goto error;
576 }
577 }
578
579 //read the sprite info and make sure it worked
580 for (int32_t i=0; i<MAXITEMS; i++)
581 {
582 if(!pfread(trashbuf,sizeof(itemdata),f))
583 {
584 goto error;
585 }
586 }
587
588 for (int32_t i=0; i<MAXWPNS; i++)
589 {
590 if(!pfread(trashbuf,sizeof(wpndata),f))
591 {
592 goto error;
593 }
594 }
595
596 //read the triforce pieces info and make sure it worked
597 for (int32_t i=0; i<8; ++i)
598 {
599 if(!p_getc(&trashbuf,f))
600 {
601 goto error;
602 }
603 }
604
605
606
607 //read the game icons info and make sure it worked
608 for (int32_t i=0; i<4; ++i)
609 {
610 if(!p_igetw(&trashbuf,f))
611 {
612 goto error;
613 }
614 }
615
616 //read the misc colors info and map styles info and make sure it worked
617 if(!pfread(trashbuf,sizeof(zcolors),f))
618 {
619 goto error;
620 }
621
622 //read the template screens and make sure it worked
623 byte num_maps;
624 if(!p_getc(&num_maps,f))
625 {
626 goto error;
627 }
628 for (int32_t i=0; i<TEMPLATES; i++)
629 {
630 if(!pfread(trashbuf,sizeof(mapscr),f))
631 {
632 goto error;
633 }
634 }
635 if (num_maps>1) //dungeon templates
636 {
637 for (int32_t i=0; i<TEMPLATES; i++)
638 {
639 if(!pfread(trashbuf,sizeof(mapscr),f))
640 {
641 goto error;
642 }
643 }
644 }
645
646 //yay! it worked! close the file and say everything was ok.
647 pack_fclose(f);
648 return true;
649
650 error:
651 pack_fclose(f);
652 return false;*/
653 }
654
655 bool valid_zqt(const char *filename)
656 {
657 PACKFILE *f=NULL;
658 bool isvalid;
659 int32_t error;
660 f=open_quest_file(&error, filename, false);
661
662 if(!f)
663 {
664 // setPackfilePassword(NULL);
665 return false;
666 }
667
668 isvalid=valid_zqt(f);
669
670 clear_quest_tmpfile();
671 pack_fclose(f);
672
673 // setPackfilePassword(NULL);
674 return isvalid;
675 }
676
677 /*
678 .qst file history
679
680 .qst files have always been compressed using allegro's packfiles.
681
682 At some point, an encoding layer was added. The two layers look like this:
683
684 1) The top layer is from us. See decode_file_007.
685 [0-24] Preamble "Zelda Classic Quest File"
686 [25-28] Initial decoding seed value.
687 [29-X] Allegro-compressed payload (AKA "packed" file), but XOR'd based on seed value
688 [last 4] Checksum
689
690 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
691 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
692 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
693 The oldest quests skip the password part.
694
695 Simply, the job of this function is to peel away the top layer.
696
697 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
698 in opening and saving files. There is no version field, so they decryption key is
699 found via trial-by-error (very slow!)
700
701 There are other file types of interest:
702 - .zqt: quest template files, skips top-layer encryption pass
703 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
704 - .qu?: same as above. automated backup files
705 - .qb?: same as above. automated backup files
706 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
707
708 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
709 files are now "slh!.AG ZC Enhanced Quest File".
710 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
711 */
712 820 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
713 {
714
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if (show_progress)
715 {
716 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
717 }
718
719 820 auto unencrypted_result = try_open_maybe_legacy_encoded_file(filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
720
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 490 times.
820 if (unencrypted_result.decoded_pf)
721 330 return unencrypted_result.decoded_pf;
722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 490 times.
490 if (unencrypted_result.not_found)
723 {
724 *open_error = qe_notfound;
725 return nullptr;
726 }
727
728 // Everything below here is legacy code - recently saved quest files will have
729 // returned by now.
730 // The only replay qst file that is still using this legacy encoding is `link_to_the_zelda.qst`.
731
732 // Note: although this is primarily for loading .qst files, it can also handle all of the
733 // file types mentioned in the comment above. No need to be told if the file being loaded
734 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
735 490 bool top_layer_compressed = unencrypted_result.top_layer_compressed;
736 490 bool compressed = unencrypted_result.compressed;
737 490 bool encrypted = unencrypted_result.encrypted;
738
739 char tmpfilename[L_tmpnam];
740 490 temp_name(tmpfilename);
741 char percent_done[30];
742 490 int32_t current_method=0;
743
744 PACKFILE *f;
745 490 const char *passwd= encrypted ? datapwd : "";
746
747 // oldquest flag is set when an unencrypted qst file is suspected.
748 490 bool oldquest = false;
749 int32_t ret;
750
751
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 if(strcmp(filename, "default.qst")!=0)
752 {
753 490 box_out(filename);
754 490 }
755 else
756 {
757 box_out("new quest"); // Or whatever
758 }
759 490 box_out("...");
760 490 box_eol();
761 490 box_eol();
762
763
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 if(encrypted)
764 {
765 490 box_out("Decrypting...");
766 490 box_save_x();
767 490 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
768
769
2/2
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 63 times.
490 if(ret)
770 {
771
1/3
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
63 switch(ret)
772 {
773 case 1:
774 box_out("error.");
775 box_eol();
776 box_end(true);
777 *open_error=qe_notfound;
778 return NULL;
779
780 case 2:
781 box_out("error.");
782 box_eol();
783 box_end(true);
784 *open_error=qe_internal;
785 return NULL;
786 // be sure not to delete tmpfilename now...
787 }
788
789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
790 {
791 63 current_method++;
792 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
793 63 box_out(percent_done);
794 63 box_load_x();
795 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
796 63 }
797
798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
799 {
800 63 current_method++;
801 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
802 63 box_out(percent_done);
803 63 box_load_x();
804 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
805 63 }
806
807
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 18 times.
63 if(ret==5) //old encryption?
808 {
809 18 current_method++;
810 18 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
811 18 box_out(percent_done);
812 18 box_load_x();
813 18 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
814 18 }
815
816
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 12 times.
63 if(ret==5) //old encryption?
817 {
818 12 current_method++;
819 12 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
820 12 box_out(percent_done);
821 12 box_load_x();
822 12 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
823 12 }
824
825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret)
826 {
827 oldquest = true;
828 passwd="";
829 }
830 63 }
831
832 490 box_out("okay.");
833 490 box_eol();
834 490 }
835 else
836 {
837 oldquest = true;
838 }
839
840 490 box_out("Opening...");
841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 490 times.
490 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
842
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 if(!f)
843 {
844 if((compressed==1)&&(errno==EDOM))
845 {
846 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
847 }
848
849 if(!f)
850 {
851 if(!oldquest)
852 {
853 delete_file(tmpfilename);
854 }
855 box_out("error.");
856 box_eol();
857 box_end(true);
858 *open_error=qe_invalid;
859 return NULL;
860 }
861 }
862
863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 490 times.
490 if(!oldquest)
864 {
865 490 delete_file(tmpfilename);
866 490 }
867
868 490 box_out("okay.");
869 490 box_eol();
870
871 490 return f;
872 820 }
873
874 PACKFILE *open_quest_template(zquestheader *Header, const char *filename, bool validate)
875 {
876 PACKFILE *f=NULL;
877 int32_t open_error=0;
878
879 if (Header->templatepath[0] != 0)
880 {
881 // TODO: should be safe to remove this, no one seems to use custom quest templates.
882 filename=Header->templatepath;
883 }
884
885 f=open_quest_file(&open_error, filename, false);
886
887 if(!f)
888 {
889 return NULL;
890 }
891
892 if(validate)
893 {
894 if(!valid_zqt(f))
895 {
896 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
897 pack_fclose(f);
898 clear_quest_tmpfile();
899 return NULL;
900 }
901 }
902
903 return f;
904 }
905
906 static bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate, const char* filename)
907 {
908 // The only time the player uses this is to init tiles for some quests 1.90 or older. See readtiles.
909 if (get_app_id() == App::zelda)
910 assert(section_id == ID_TILES);
911
912 combosread=false;
913 mapsread=false;
914 fixffcs=false;
915
916 switch(section_id)
917 {
918 case ID_RULES:
919 case ID_STRINGS:
920 case ID_MISC:
921 case ID_TILES:
922 case ID_COMBOS:
923 case ID_CSETS:
924 case ID_MAPS:
925 case ID_DMAPS:
926 case ID_DOORS:
927 case ID_ITEMS:
928 case ID_WEAPONS:
929 case ID_COLORS:
930 case ID_ICONS:
931 case ID_INITDATA:
932 case ID_GUYS:
933 case ID_MIDIS:
934 case ID_CHEATS:
935 case ID_ITEMDROPSETS:
936 case ID_FAVORITES:
937 break;
938
939 default:
940 return false;
941 break;
942 }
943
944 int32_t ret;
945 word version, build;
946 PACKFILE *f=NULL;
947
948 //why is this here?
949 /*
950 if(colordata==NULL)
951 return false;
952 */
953
954 //setPackfilePassword(datapwd);
955 f=open_quest_template(Header, filename, validate);
956
957 if(!f) //no file, nothing to delete
958 {
959 // setPackfilePassword(NULL);
960 return false;
961 }
962
963 ret=get_version_and_build(f, &version, &build);
964
965 if(ret||(version==0))
966 {
967 pack_fclose(f);
968 clear_quest_tmpfile();
969
970 // setPackfilePassword(NULL);
971 return false;
972 }
973
974 if(!find_section(f, section_id))
975 {
976 al_trace("Can't find section!\n");
977 pack_fclose(f);
978 clear_quest_tmpfile();
979
980 //setPackfilePassword(NULL);
981 return false;
982 }
983
984 switch(section_id)
985 {
986 case ID_RULES:
987 //rules
988 ret=readrules(f, Header);
989 break;
990
991 case ID_STRINGS:
992 //strings
993 ret=readstrings(f, Header);
994 break;
995
996 case ID_MISC:
997 //misc data
998 ret=readmisc(f, Header, Misc);
999 break;
1000
1001 case ID_TILES:
1002 //tiles
1003 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1004 break;
1005
1006 case ID_COMBOS:
1007 //combos
1008 clear_combos();
1009 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1010 combosread=true;
1011 break;
1012
1013 case ID_COMBOALIASES:
1014 //combos
1015 ret=readcomboaliases(f, Header, version, build);
1016 break;
1017
1018 case ID_CSETS:
1019 //color data
1020 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1021 break;
1022
1023 case ID_MAPS:
1024 //maps
1025 ret=readmaps(f, Header);
1026 mapsread=true;
1027 break;
1028
1029 case ID_DMAPS:
1030 //dmaps
1031 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1032 break;
1033
1034 case ID_DOORS:
1035 //door combo sets
1036 ret=readdoorcombosets(f, Header);
1037 break;
1038
1039 case ID_ITEMS:
1040 //items
1041 ret=readitems(f, version, build);
1042 break;
1043
1044 case ID_WEAPONS:
1045 //weapons
1046 ret=readweapons(f, Header);
1047 break;
1048
1049 case ID_COLORS:
1050 //misc. colors
1051 ret=readmisccolors(f, Header, Misc);
1052 break;
1053
1054 case ID_ICONS:
1055 //game icons
1056 ret=readgameicons(f, Header, Misc);
1057 break;
1058
1059 case ID_INITDATA:
1060 //initialization data
1061 ret=readinitdata(f, Header);
1062 break;
1063
1064 case ID_GUYS:
1065 //guys
1066 ret=readguys(f, Header);
1067 break;
1068
1069 case ID_MIDIS:
1070 //midis
1071 ret=readmidis(f, Header, tunes);
1072 break;
1073
1074 case ID_CHEATS:
1075 //cheat codes
1076 ret=readcheatcodes(f, Header);
1077 break;
1078
1079 case ID_ITEMDROPSETS:
1080 //item drop sets
1081 // Why is this one commented out?
1082 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1083 break;
1084
1085 case ID_FAVORITES:
1086 // favorite combos and aliases
1087 ret=readfavorites(f, version);
1088 break;
1089
1090 default:
1091 ret=-1;
1092 break;
1093 }
1094
1095 pack_fclose(f);
1096 clear_quest_tmpfile();
1097
1098 //setPackfilePassword(NULL);
1099 if(!ret)
1100 {
1101 return true;
1102 }
1103
1104 return false;
1105 }
1106
1107 bool init_tiles_for_190(bool validate, zquestheader *Header)
1108 {
1109 return init_section(Header, ID_TILES, NULL, NULL, validate, "assets/190_tiles.qst");
1110 }
1111
1112 bool init_tiles(bool validate, zquestheader *Header)
1113 {
1114 return init_section(Header, ID_TILES, NULL, NULL, validate, "modules/classic/default.qst");
1115 }
1116
1117 bool init_combos(bool validate, zquestheader *Header)
1118 {
1119 return init_section(Header, ID_COMBOS, NULL, NULL, validate, "modules/classic/default.qst");
1120 }
1121
1122 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1123 {
1124 return init_section(Header, ID_CSETS, Misc, NULL, validate, "modules/classic/default.qst");
1125 }
1126
1127 820 void init_spritelists()
1128 {
1129
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 208 times.
820 if(FFCore.quest_format[vZelda] < 0x255)
1130 {
1131 612 guys.setMax(255);
1132 612 items.setMax(255);
1133 612 Ewpns.setMax(255);
1134 612 Lwpns.setMax(255);
1135 612 chainlinks.setMax(255);
1136 612 decorations.setMax(255);
1137 612 particles.setMax(255);
1138 612 }
1139 else
1140 {
1141 208 guys.setMax(255);
1142 208 items.setMax(255);
1143 208 Ewpns.setMax(255);
1144 208 Lwpns.setMax(255);
1145 208 chainlinks.setMax(255);
1146 208 decorations.setMax(255);
1147 208 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1148 }
1149 820 }
1150
1151 321 bool reset_items(bool validate, zquestheader *Header)
1152 {
1153 321 bool ret = true;
1154
1/2
✓ Branch 0 taken 321 times.
✗ Branch 1 not taken.
321 if (get_app_id() == App::zquest)
1155 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate, "modules/classic/default.qst");
1156
1157
2/2
✓ Branch 0 taken 321 times.
✓ Branch 1 taken 82176 times.
82497 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1158
1159 321 return ret;
1160 }
1161
1162 bool reset_guys()
1163 {
1164 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1165 init_guys(V_GUYS);
1166 return true;
1167 }
1168
1169 bool reset_wpns(bool validate, zquestheader *Header)
1170 {
1171 bool ret = true;
1172 if (get_app_id() == App::zquest)
1173 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate, "modules/classic/default.qst");
1174
1175 for(int32_t i=0; i<MAXWPNS; i++)
1176 reset_weaponname(i);
1177
1178 return ret;
1179 }
1180
1181 bool reset_mapstyles(bool validate, miscQdata *Misc)
1182 {
1183 Misc->colors.blueframe_tile = 20044;
1184 Misc->colors.blueframe_cset = 0;
1185 Misc->colors.triforce_tile = 23461;
1186 Misc->colors.triforce_cset = 1;
1187 Misc->colors.triframe_tile = 18752;
1188 Misc->colors.triframe_cset = 1;
1189 Misc->colors.overworld_map_tile = 16990;
1190 Misc->colors.overworld_map_cset = 2;
1191 Misc->colors.HCpieces_tile = 21160;
1192 Misc->colors.HCpieces_cset = 8;
1193 Misc->colors.dungeon_map_tile = 19651;
1194 Misc->colors.dungeon_map_cset = 8;
1195 return true;
1196 }
1197
1198 1264538 int32_t read_weap_data(weapon_data& data, PACKFILE* f)
1199 {
1200 word v_weapon_data;
1201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1264538 times.
1264538 if(!p_igetw(&v_weapon_data,f))
1202 return qe_invalid;
1203
1204
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_igetw(&(data.flags), f))
1205 return qe_invalid;
1206
1207
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_igetl(&(data.moveflags), f))
1208 return qe_invalid;
1209
1210
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_igetw(&(data.wflags), f))
1211 return qe_invalid;
1212
1213
2/2
✓ Branch 0 taken 6322690 times.
✓ Branch 1 taken 1264538 times.
7587228 for (int32_t q = 0; q < WPNSPR_MAX; ++q)
1214 {
1215
1/2
✓ Branch 0 taken 6322690 times.
✗ Branch 1 not taken.
6322690 if (!p_getc(&(data.burnsprs[q]), f))
1216 return qe_invalid;
1217
1/2
✓ Branch 0 taken 6322690 times.
✗ Branch 1 not taken.
6322690 if (!p_getc(&(data.light_rads[q]), f))
1218 return qe_invalid;
1219 6322690 }
1220
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_getc(&(data.glow_shape), f))
1221 return qe_invalid;
1222
1223
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_igetl(&(data.override_flags), f))
1224 return qe_invalid;
1225
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_igetl(&(data.tilew), f))
1226 return qe_invalid;
1227
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_igetl(&(data.tileh), f))
1228 return qe_invalid;
1229
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_igetl(&(data.hxsz), f))
1230 return qe_invalid;
1231
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_igetl(&(data.hysz), f))
1232 return qe_invalid;
1233
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_igetl(&(data.hzsz), f))
1234 return qe_invalid;
1235
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_igetl(&(data.hxofs), f))
1236 return qe_invalid;
1237
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_igetl(&(data.hyofs), f))
1238 return qe_invalid;
1239
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_igetl(&(data.xofs), f))
1240 return qe_invalid;
1241
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_igetl(&(data.yofs), f))
1242 return qe_invalid;
1243
1244
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_igetzf(&(data.step), f))
1245 return qe_invalid;
1246
1247
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_getc(&(data.unblockable), f))
1248 return qe_invalid;
1249
1250
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_igetl(&(data.timeout), f))
1251 return qe_invalid;
1252
1253
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_getc(&(data.imitate_weapon), f))
1254 return qe_invalid;
1255
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_getc(&(data.default_defense), f))
1256 return qe_invalid;
1257
1258
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_getc(&(data.lift_level), f))
1259 return qe_invalid;
1260
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_getc(&(data.lift_time), f))
1261 return qe_invalid;
1262
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if (!p_igetzf(&(data.lift_height), f))
1263 return qe_invalid;
1264
1265
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if(!p_igetw(&(data.script), f))
1266 return qe_invalid;
1267
2/2
✓ Branch 0 taken 10116304 times.
✓ Branch 1 taken 1264538 times.
11380842 for(uint q = 0; q < 8; ++q)
1268
1/2
✓ Branch 0 taken 10116304 times.
✗ Branch 1 not taken.
10116304 if(!p_igetl(&(data.initd[q]), f))
1269 return qe_invalid;
1270
1/2
✓ Branch 0 taken 1264538 times.
✗ Branch 1 not taken.
1264538 if(!p_igetw(&(data.pierce_count), f))
1271 return qe_invalid;
1272 1264538 return 0;
1273 1264538 }
1274
1275 380 int32_t get_qst_buffers()
1276 {
1277 380 TheMaps.resize(MAPSCRS);
1278 380 old_combo_pages.resize(MAPSCRS);
1279 380 map_infos.resize(1);
1280
1281 380 Z_message("OK\n");
1282
1283 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1284 // (Shoelace's "Hero of Dreams" uses 1415.)
1285 // So let's be a bit generous and allow 4096 initially.
1286 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1287 // I tested it and it worked without flaw on 6/6/11. - L.
1288 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1289 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1290 // See https://discord.com/channels/876899628556091432/992984989073416242
1291 380 msg_strings_size = 8192;
1292
1293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 380 times.
380 MsgStrings = new MsgStr[msg_strings_size];
1294
1295 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1296
2/2
✓ Branch 0 taken 3112960 times.
✓ Branch 1 taken 380 times.
3113340 for(auto q = 0; q < msg_strings_size; ++q)
1297 {
1298 3112960 MsgStrings[q].clear();
1299 3112960 }
1300
1301
4/6
✓ Branch 0 taken 194560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 194180 times.
✓ Branch 3 taken 380 times.
✓ Branch 4 taken 380 times.
✗ Branch 5 not taken.
194560 if((DMaps=new dmap[MAXDMAPS])==NULL)
1302 return 0;
1303
1304
1305
1306 380 combobuf.clear();
1307 380 combobuf.resize(MAXCOMBOS);
1308
1309
1310
1/2
✓ Branch 0 taken 380 times.
✗ Branch 1 not taken.
380 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1311 return 0;
1312
1313 380 free_newtilebuf();
1314
1/2
✓ Branch 0 taken 380 times.
✗ Branch 1 not taken.
380 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1315 return 0;
1316
1317 380 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1318 //Z_message("Performed memset on tiles\n");
1319 380 clear_tiles(newtilebuf);
1320 //Z_message("Performed clear_tiles()\n");
1321
1322
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 13 times.
380 if (get_app_id() == App::zquest)
1323 {
1324
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1325 return 0;
1326
1327 13 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1328 13 clear_tiles(grabtilebuf);
1329 13 }
1330
1331
1/2
✓ Branch 0 taken 380 times.
✗ Branch 1 not taken.
380 if((trashbuf=(byte*)malloc(100000))==NULL)
1332 return 0;
1333
1334 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1335 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1336 // fixed by ensuring there's actually itemdata there.
1337 // If you change this, be sure to update del_qst_buffers, too.
1338
1339
1/2
✓ Branch 0 taken 380 times.
✗ Branch 1 not taken.
380 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1340 return 0;
1341
1342
2/2
✓ Branch 0 taken 97660 times.
✓ Branch 1 taken 380 times.
98040 for(size_t q = 0; q < MAXITEMS+1; ++q)
1343 97660 itemsbuf[q].clear();
1344 380 itemsbuf++;
1345
1346
1/2
✓ Branch 0 taken 380 times.
✗ Branch 1 not taken.
380 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1347 return 0;
1348
1349 380 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1350
1351
1/2
✓ Branch 0 taken 380 times.
✗ Branch 1 not taken.
380 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1352 return 0;
1353
1354
2/2
✓ Branch 0 taken 194560 times.
✓ Branch 1 taken 380 times.
194940 for(size_t q = 0; q < MAXGUYS; ++q)
1355 194560 guysbuf[q].clear();
1356
1357
1/2
✓ Branch 0 taken 380 times.
✗ Branch 1 not taken.
380 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1358 return 0;
1359
1360 380 return 1;
1361 380 }
1362
1363
1364 712 void free_newtilebuf()
1365 {
1366
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 379 times.
712 if(newtilebuf)
1367 {
1368
2/2
✓ Branch 0 taken 71428500 times.
✓ Branch 1 taken 333 times.
71428833 for(int32_t i=0; i<NEWMAXTILES; i++)
1369
2/2
✓ Branch 0 taken 214500 times.
✓ Branch 1 taken 71214000 times.
142642500 if(newtilebuf[i].data)
1370 71214000 free(newtilebuf[i].data);
1371
1372 333 free(newtilebuf);
1373 333 newtilebuf = 0;
1374 333 }
1375 712 }
1376
1377 332 void free_grabtilebuf()
1378 {
1379
2/2
✓ Branch 0 taken 321 times.
✓ Branch 1 taken 11 times.
332 if (get_app_id() == App::zquest)
1380 {
1381
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(grabtilebuf)
1382 {
1383
2/2
✓ Branch 0 taken 2359500 times.
✓ Branch 1 taken 11 times.
2359511 for(int32_t i=0; i<NEWMAXTILES; i++)
1384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2359500 times.
2359500 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1385
1386 11 free(grabtilebuf);
1387 11 grabtilebuf = 0;
1388 11 }
1389 11 }
1390 332 }
1391
1392 332 void del_qst_buffers()
1393 {
1394
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
✓ Branch 2 taken 332 times.
✗ Branch 3 not taken.
332 if(MsgStrings) delete[] MsgStrings;
1395
1396
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
✓ Branch 2 taken 332 times.
✗ Branch 3 not taken.
332 if (DMaps) delete[] DMaps;
1397
1398 332 combobuf.clear();
1399
1400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(colordata) free(colordata);
1401
1402 332 free_newtilebuf();
1403 332 free_grabtilebuf();
1404
1405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(trashbuf) free(trashbuf);
1406
1407 // See get_qst_buffers
1408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(itemsbuf)
1409 {
1410 332 itemsbuf--;
1411 332 free(itemsbuf);
1412 332 }
1413
1414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(wpnsbuf) free(wpnsbuf);
1415
1416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(guysbuf) free(guysbuf);
1417
1418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(combo_class_buf) free(combo_class_buf);
1419 332 }
1420
1421 18 bool init_palnames()
1422 {
1423 // if(palnames==NULL)
1424 // return false;
1425
1426
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 18 times.
9234 for(int32_t x=0; x<MAXLEVELS; x++)
1427 {
1428
4/4
✓ Branch 0 taken 9162 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 18 times.
9216 switch(x)
1429 {
1430 case 0:
1431 18 sprintf(palnames[x],"Overworld");
1432 18 break;
1433
1434 case 10:
1435 18 sprintf(palnames[x],"Caves");
1436 18 break;
1437
1438 case 11:
1439 18 sprintf(palnames[x],"Passageways");
1440 18 break;
1441
1442 default:
1443 9162 sprintf(palnames[x],"%c",0);
1444 9162 break;
1445 }
1446 9216 }
1447
1448 18 return true;
1449 }
1450
1451 100429 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1452 {
1453 void *p;
1454
1455
1/2
✓ Branch 0 taken 100429 times.
✗ Branch 1 not taken.
100429 p = _AL_MALLOC(MAX(size, alloc_size));
1456
1457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100429 times.
100429 if(!p)
1458 {
1459 return NULL;
1460 }
1461
1462
1/2
✓ Branch 0 taken 100429 times.
✗ Branch 1 not taken.
100429 if(!pfread(p,size,f))
1463 {
1464 _AL_FREE(p);
1465 return NULL;
1466 }
1467
1468
1/2
✓ Branch 0 taken 100429 times.
✗ Branch 1 not taken.
100429 if(pack_ferror(f))
1469 {
1470 _AL_FREE(p);
1471 return NULL;
1472 }
1473
1474 100429 return p;
1475 100429 }
1476
1477 // Only use for reading parts of older quests (Header->zelda_version <= 0x192)
1478 static const byte* legacy_skip_flags;
1479
1480 /* read_midi:
1481 * Reads MIDI data from a datafile (this is not the same thing as the
1482 * standard midi file format).
1483 */
1484
1485 10300 static MIDI *read_midi(PACKFILE *f)
1486 {
1487 MIDI *m;
1488 int32_t c;
1489 10300 int16_t divisions=0;
1490 10300 int32_t len=0;
1491
1492 10300 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1493
1494
1/2
✓ Branch 0 taken 10300 times.
✗ Branch 1 not taken.
10300 if(!m)
1495 {
1496 return NULL;
1497 }
1498
1499
2/2
✓ Branch 0 taken 329600 times.
✓ Branch 1 taken 10300 times.
339900 for(c=0; c<MIDI_TRACKS; c++)
1500 {
1501 329600 m->track[c].len = 0;
1502 329600 m->track[c].data = NULL;
1503 329600 }
1504
1505 10300 p_mgetw(&divisions,f);
1506 10300 m->divisions=divisions;
1507
1508
2/2
✓ Branch 0 taken 329600 times.
✓ Branch 1 taken 10300 times.
339900 for(c=0; c<MIDI_TRACKS; c++)
1509 {
1510 329600 p_mgetl(&len,f);
1511 329600 m->track[c].len=len;
1512
1513
2/2
✓ Branch 0 taken 229171 times.
✓ Branch 1 taken 100429 times.
329600 if(m->track[c].len > 0)
1514 {
1515 100429 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1516
1517
1/2
✓ Branch 0 taken 100429 times.
✗ Branch 1 not taken.
100429 if(!m->track[c].data)
1518 {
1519 destroy_midi(m);
1520 return NULL;
1521 }
1522 100429 }
1523 329600 }
1524
1525 LOCK_DATA(m, sizeof(MIDI));
1526
1527
2/2
✓ Branch 0 taken 329600 times.
✓ Branch 1 taken 10300 times.
339900 for(c=0; c<MIDI_TRACKS; c++)
1528 {
1529
2/2
✓ Branch 0 taken 100429 times.
✓ Branch 1 taken 229171 times.
329600 if(m->track[c].data)
1530 {
1531 LOCK_DATA(m->track[c].data, m->track[c].len);
1532 100429 }
1533 329600 }
1534
1535 10300 return m;
1536 10300 }
1537
1538 void clear_combo(int32_t i)
1539 {
1540 combobuf[i].clear();
1541 }
1542
1543 void clear_combos()
1544 {
1545 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1546 clear_combo(tmpcounter);
1547 }
1548
1549 void pack_combos()
1550 {
1551 int32_t di = 0;
1552
1553 for(int32_t si=0; si<1024; si+=2)
1554 combobuf[di++] = combobuf[si];
1555
1556 for(; di<1024; di++)
1557 clear_combo(di);
1558 }
1559
1560 490 void reset_tunes(zctune *tune)
1561 {
1562
2/2
✓ Branch 0 taken 123480 times.
✓ Branch 1 taken 490 times.
123970 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1563 {
1564 123480 tune[i].reset();
1565 123480 }
1566 490 }
1567
1568 int32_t doortranslations_u[9][4]=
1569 {
1570 {37,38,53,54},
1571 {37,38,39,40},
1572 {37,38,55,56},
1573 {37,38,39,40},
1574 {37,38,53,54},
1575 {37,38,53,54},
1576 {37,38,53,54},
1577 {7,8,23,24},
1578 {7,8,41,42}
1579 };
1580
1581 int32_t doortranslations_d[9][4]=
1582 {
1583 {117,118,133,134},
1584 {135,136,133,134},
1585 {119,120,133,134},
1586 {135,136,133,134},
1587 {117,118,133,134},
1588 {117,118,133,134},
1589 {117,118,133,134},
1590 {151,152,167,168},
1591 {137,138,167,168},
1592 };
1593
1594 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1595 int32_t doortranslations_l[9][6]=
1596 {
1597 {66,67,82,83,98,99},
1598 {66,68,82,84,98,100},
1599 {66,69,82,85,98,101},
1600 {66,68,82,84,98,100},
1601 {66,67,82,83,98,99},
1602 {66,67,82,83,98,99},
1603 {66,67,82,83,98,99},
1604 {64,65,80,81,96,97},
1605 {64,65,80,114,96,97},
1606 };
1607
1608 int32_t doortranslations_r[9][6]=
1609 {
1610
1611 {76,77,92,93,108,109},
1612 {75,77,91,93,107,109},
1613 {74,77,90,93,106,109},
1614 {75,77,91,93,107,109},
1615 {76,77,92,93,108,109},
1616 {76,77,92,93,108,109},
1617 {76,77,92,93,108,109},
1618 {78,79,94,95,110,111},
1619 {78,79,125,95,110,111},
1620 };
1621
1622 858450 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1623 {
1624 858450 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1625 858450 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF) + (old_cpage<<8);
1626 }
1627
1628 840750 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1629 {
1630 //these are here to bypass compiler warnings about unused arguments
1631 840750 map=map;
1632 840750 scr=scr;
1633 840750 pos=pos;
1634
1635 //what does this function do?
1636 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1637 840750 return 2;
1638 }
1639
1640 22848 int32_t MakeDoors(int32_t map, int32_t scr)
1641 {
1642
2/2
✓ Branch 0 taken 18423 times.
✓ Branch 1 taken 4425 times.
22848 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1643 {
1644 18423 return 0;
1645 }
1646
1647 4425 DoorComboSet tempdcs{};
1648
1649 //up
1650
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1651 {
1652
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1653 {
1654 159300 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1655 159300 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1656 159300 }
1657 39825 }
1658
1659 4425 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1660 4425 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1661 4425 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1662 4425 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1663 4425 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1664 4425 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1665
1666 //down
1667
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1668 {
1669
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1670 {
1671 159300 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1672 159300 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1673 159300 }
1674 39825 }
1675
1676 4425 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1677
1678 4425 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1679 4425 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1680 4425 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1681 4425 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1682 4425 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1683
1684 //left
1685 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1686
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1687 {
1688
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1689 {
1690 238950 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1691 238950 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1692 238950 }
1693 39825 }
1694
1695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1696 {
1697 if((j!=2)&&(j!=3))
1698 {
1699 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1700 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1701 }
1702 }
1703
1704 4425 tempdcs.bombdoorcombo_l[0]=0;
1705 4425 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1706 4425 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1707 4425 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1708 4425 tempdcs.bombdoorcombo_l[2]=0;
1709 4425 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1710 4425 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1711 4425 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1712
1713 //right
1714
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1715 {
1716
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1717 {
1718 238950 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1719 238950 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1720 238950 }
1721 39825 }
1722
1723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1724 {
1725 if((j!=2)&&(j!=3))
1726 {
1727 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1728 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1729 }
1730 }
1731
1732 4425 tempdcs.bombdoorcombo_r[0]=0;
1733 4425 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1734 4425 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1735 4425 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1736 4425 tempdcs.bombdoorcombo_r[2]=0;
1737 4425 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1738 4425 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1739 4425 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1740
1741 int32_t k;
1742
1743
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 10306 times.
10366 for(k=0; k<door_combo_set_count; k++)
1744 {
1745
2/2
✓ Branch 0 taken 5941 times.
✓ Branch 1 taken 4365 times.
10306 if(DoorComboSets[k]==tempdcs)
1746 {
1747 4365 break;
1748 }
1749 5941 }
1750
1751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 if (k >= DoorComboSets.size())
1752 {
1753 return 0;
1754 }
1755
1756
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 4365 times.
4425 if(k==door_combo_set_count)
1757 {
1758 60 DoorComboSets[k]=tempdcs;
1759 60 DoorComboSetNames[k] = fmt::format("Door Combo Set {}", k);
1760 60 ++door_combo_set_count;
1761 60 }
1762
1763 4425 return k;
1764 /*
1765 doorcombo_u[9][4];
1766 doorcset_u[9][4];
1767 doorcombo_d[9][4];
1768 doorcset_d[9][4];
1769 doorcombo_l[9][6];
1770 doorcset_l[9][6];
1771 doorcombo_r[9][6];
1772 doorcset_r[9][6];
1773 bombdoorcombo_u[2];
1774 bombdoorcset_u[2];
1775 bombdoorcombo_d[2];
1776 bombdoorcset_d[2];
1777 bombdoorcombo_l[3];
1778 bombdoorcset_l[3];
1779 bombdoorcombo_r[3];
1780 bombdoorcset_r[3];
1781 walkthroughcombo[4];
1782 walkthroughcset[4];
1783 */
1784 22848 }
1785
1786 2924544 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1787 {
1788 2924544 byte old_cpage = old_combo_pages[map*MAPSCRS+scr];
1789 2924544 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF) + (old_cpage<<8);
1790 }
1791
1792 2924544 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1793 {
1794
1795 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1796 }
1797
1798 2924544 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1799 {
1800 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1801 }
1802
1803
1804 83 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1805 {
1806 char temp_pwd[30];
1807 83 memset(temp_pwd,0,30);
1808
1809
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 8 times.
83 if(pwdkey!=0)
1810 {
1811 75 memcpy(temp_pwd,encrypted_pwd,30);
1812 75 temp_pwd[29]=0;
1813
1814
2/2
✓ Branch 0 taken 2250 times.
✓ Branch 1 taken 75 times.
2325 for(int32_t i=0; i<30; i++)
1815 {
1816 2250 temp_pwd[i] -= pwdkey;
1817 2250 int32_t t=pwdkey>>15;
1818 2250 pwdkey = (pwdkey<<1)+t;
1819 2250 }
1820 75 }
1821
1822 83 memcpy(pwd,temp_pwd,30);
1823 83 }
1824
1825
1826 262 bool devpwd()
1827 {
1828 #ifdef _DEBUG
1829 return true;
1830 #endif
1831 #if DEVLEVEL > 3
1832 return true;
1833 #endif
1834
1/2
✓ Branch 0 taken 262 times.
✗ Branch 1 not taken.
262 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio) || is_ci();
1835 }
1836 bool check_questpwd(zquestheader *Header, char *pwd)
1837 {
1838 if(devpwd())
1839 return true;
1840 if((!strcmp(pwd, (char*)clavio)))
1841 return true;
1842 cvs_MD5Context ctx;
1843 uint8_t md5sum[16];
1844
1845 cvs_MD5Init(&ctx);
1846 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
1847 cvs_MD5Final(md5sum, &ctx);
1848
1849 return (memcmp(Header->pwd_hash,md5sum,16)==0);
1850 }
1851
1852 static char const* key_exts[KEYFILE_NUMTY] = {"key", "zcheat", "zpwd"};
1853 static bool key_hashed[KEYFILE_NUMTY] = {false, true, false};
1854 static char const* key_namestr[KEYFILE_NUMTY] = {"Master","Cheat","ZPwd"};
1855
1856 static bool check_keyfile(char const* path, char const* ext, bool hashed, char const* typestr, zquestheader* Header)
1857 {
1858 char keyfilename[2048];
1859 replace_extension(keyfilename, path, ext, 2047);
1860 if(!exists(keyfilename))
1861 return false;
1862 bool ret = false;
1863
1864 char password[QSTPWD_LEN] = {0}, pwd[32] = {0};
1865 PACKFILE *fp = pack_fopen_password(keyfilename, F_READ,"");
1866 char msg[80] = {0};
1867 pfread(msg, 80, fp);
1868 if(strcmp(msg,"ZQuest Auto-Generated Quest Password Key File. DO NOT EDIT!"))
1869 {
1870 zprint2("Found %s Key File '%s' (invalid header)\n", typestr, keyfilename);
1871 pack_fclose(fp);
1872 return false;
1873 }
1874 int16_t ver;
1875 byte bld;
1876 p_igetw(&ver, fp);
1877 p_getc(&bld, fp);
1878 pfread(password, QSTPWD_LEN, fp, true);
1879 if(hashed)
1880 {
1881 char unhashed_pw[QSTPWD_LEN] = {0};
1882
1883 char hashmap = 'Z';
1884 hashmap += 'Q';
1885 hashmap += 'U';
1886 hashmap += 'E';
1887 hashmap += 'S';
1888 hashmap += 'T';
1889
1890 for ( int32_t q = 0; q < QSTPWD_LEN; ++q )
1891 unhashed_pw[q] = password[q] - hashmap;
1892
1893 ret = check_questpwd(Header, unhashed_pw);
1894 }
1895 else ret = check_questpwd(Header, password);
1896 pack_fclose(fp);
1897 zprint2("Found %s Key File '%s' (%s access)\n",
1898 typestr, keyfilename, ret ? "valid" : "invalid");
1899 return ret;
1900 }
1901
1902 bool check_keyfiles(char const* path, vector<uint> types, zquestheader* Header)
1903 {
1904 char exedir[PATH_MAX] = {0};
1905 extract_name(path, exedir, FILENAMEALL);
1906 char const* paths[] = {path, exedir};
1907 for(uint keyty : types)
1908 {
1909 if(keyty >= KEYFILE_NUMTY)
1910 continue;
1911 for(char const* p : paths)
1912 {
1913 if(check_keyfile(p, key_exts[keyty], key_hashed[keyty], key_namestr[keyty], Header))
1914 return true;
1915 }
1916 }
1917 return false;
1918 }
1919
1920 491 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
1921 {
1922 491 zprint2("\n");
1923 491 zprint2("[QUEST METADATA]\n");
1924
1/2
✓ Branch 0 taken 491 times.
✗ Branch 1 not taken.
491 if(path)
1925 491 zprint2("Path: %s\n", path);
1926
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 122 times.
491 if(tempheader.title[0])
1927 369 zprint2("Title: %s\n", tempheader.title);
1928 491 zprint2("ZC Version: %s\n", tempheader.getVerStr());
1929
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 283 times.
491 if(tempheader.new_version_id_date_day)
1930 208 zprint2("ZC Build Date: %d-%d-%d %s %s\n", tempheader.new_version_id_date_year, tempheader.new_version_id_date_month, tempheader.new_version_id_date_day, tempheader.build_timestamp, tempheader.build_timezone);
1931
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 214 times.
491 if(tempheader.version[0])
1932 277 zprint2("Qst Version: %s\n", tempheader.version);
1933
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 122 times.
491 if(tempheader.author[0])
1934 369 zprint2("Author: %s\n", tempheader.author);
1935 491 zprint2("\n");
1936 491 }
1937
1938 832 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
1939 {
1940 int32_t dummy;
1941 832 zquestheader tempheader{};
1942
2/2
✓ Branch 0 taken 820 times.
✓ Branch 1 taken 12 times.
832 tempheader.filename = Header->filename;
1943 char dummybuf[80];
1944 byte temp_map_count;
1945 byte temp_midi_flags[MIDIFLAGS_SIZE];
1946 word version;
1947 char temp_pwd[30], temp_pwd2[30];
1948 int16_t temp_pwdkey;
1949 cvs_MD5Context ctx;
1950 820 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
1951 820 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
1952
1953
1954
1955
2/4
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 820 times.
820 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
1956 {
1957 Z_message("Unable to read header string\n");
1958 return qe_invalid;
1959 }
1960
1961 // check header
1962
2/2
✓ Branch 0 taken 796 times.
✓ Branch 1 taken 24 times.
820 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
1963 {
1964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1965 {
1966 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
1967 return qe_invalid;
1968 }
1969 24 }
1970
1971 820 int32_t templatepath_len=0;
1972
1973 820 tempheader.external_zinfo = false;
1974 820 read_zinfo = false;
1975
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 796 times.
820 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
1976 {
1977 byte padding;
1978
1979
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
1980 {
1981 return qe_invalid;
1982 }
1983
1984
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&tempheader.zelda_version,f))
1985 {
1986 return qe_invalid;
1987 }
1988
1989 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1990
1991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version > ZELDA_VERSION)
1992 {
1993 return qe_version;
1994 }
1995
1996 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
1997
1998
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
1999 {
2000 return qe_invalid;
2001 }
2002
2003
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(bad_version(tempheader.zelda_version))
2004 {
2005 return qe_obsolete;
2006 }
2007
2008
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&tempheader.internal,f))
2009 {
2010 return qe_invalid;
2011 }
2012
2013
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.quest_number,f))
2014 {
2015 return qe_invalid;
2016 }
2017
2018 24 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2019
2020
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[0],2,f))
2021 {
2022 return qe_invalid;
2023 }
2024
2025
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&temp_map_count,f))
2026 {
2027 return qe_invalid;
2028 }
2029
2030 24 FFCore.quest_format[qMapCount] = temp_map_count;
2031
2032
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.old_str_count,f))
2033 {
2034 return qe_invalid;
2035 }
2036
2037
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2038 {
2039 return qe_invalid;
2040 }
2041
2042
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(temp_midi_flags,4,f))
2043 {
2044 return qe_invalid;
2045 }
2046
2047
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2048 {
2049 return qe_invalid;
2050 }
2051
2052
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,14,f))
2053 {
2054 return qe_invalid;
2055 }
2056
2057
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(&quest_rules[2],2,f))
2058 {
2059 return qe_invalid;
2060 }
2061
2062
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&dummybuf,f))
2063 {
2064 return qe_invalid;
2065 }
2066
2067
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.version,9,f))
2068 {
2069 return qe_invalid;
2070 }
2071
2072
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2073 {
2074 return qe_invalid;
2075 }
2076 // These fields are expected to end in null bytes!
2077 24 tempheader.title[sizeof(tempheader.title)-1] = 0;
2078
2079
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2080 {
2081 return qe_invalid;
2082 }
2083 24 tempheader.author[sizeof(tempheader.author)-1] = 0;
2084
2085
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&padding,f))
2086 {
2087 return qe_invalid;
2088 }
2089
2090
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_igetw(&temp_pwdkey,f))
2091 {
2092 return qe_invalid;
2093 }
2094
2095
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(temp_pwd,30,f))
2096 {
2097 return qe_invalid;
2098 }
2099
2100 24 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2101
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Init(&ctx);
2102
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2103
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2104
2105
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2106 {
2107 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2108 // Not anymore...
2109 memset(tempheader.minver,0,17);
2110 tempheader.build=0;
2111 tempheader.use_keyfile=0;
2112 memset(tempheader.old_foo, 0, 9);
2113 }
2114 else
2115 {
2116
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(tempheader.minver,9,f))
2117 {
2118 return qe_invalid;
2119 }
2120
2121
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.build,f))
2122 {
2123 return qe_invalid;
2124 }
2125
2126 24 FFCore.quest_format[vBuild] = tempheader.build;
2127
2128
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!p_getc(&tempheader.use_keyfile,f))
2129 {
2130 return qe_invalid;
2131 }
2132
2133
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 if(!pfread(dummybuf,9,f))
2134 {
2135 return qe_invalid;
2136 }
2137 } // starting at minver
2138
2139
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2140 {
2141 6 memset(&quest_rules[4],0,16); // word rules3..rules10
2142 6 }
2143 else
2144 {
2145
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2146 {
2147 return qe_invalid; // starting at rules3
2148 }
2149
2150
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 if(tempheader.zelda_version <= 0x190)
2151 {
2152
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 set_qr(qr_MEANPLACEDTRAPS,0);
2153 12 }
2154 }
2155
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 unpack_qrs();
2156
2157
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2158
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2159 {
2160
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2161
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,(get_qr(qr_BRKBLSHLDS_DEP)));
2162
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 set_qr(qr_BRKBLSHLDS_DEP,0);
2163 18 }
2164
2165
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2166 {
2167 6 byte *mf=temp_midi_flags;
2168
2169
3/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
6 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2170 {
2171 4 mf=(byte*)dummybuf;
2172 4 }
2173
2174
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(mf,32,f)) // read new header additions
2175 {
2176 return qe_invalid; // starting at foo2
2177 }
2178
2179
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!pfread(dummybuf,18,f)) // read new header additions
2180 {
2181 return qe_invalid; // starting at foo2
2182 }
2183 6 }
2184
2185
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
24 if((tempheader.zelda_version < 0x192)||
2186
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2187 {
2188 18 memset(tempheader.templatepath,0,2048);
2189 18 }
2190 else
2191 {
2192 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2193 {
2194 return qe_invalid;
2195 }
2196 }
2197
2198
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2199
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2200 {
2201 24 tempheader.use_keyfile=0;
2202 24 }
2203 24 }
2204 else
2205 {
2206 //section id
2207
2/4
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 796 times.
✗ Branch 3 not taken.
796 if(!p_mgetl(&dummy,f))
2208 {
2209 return qe_invalid;
2210 }
2211
2212 //section version info
2213
2/4
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 796 times.
✗ Branch 3 not taken.
796 if(!p_igetw(&version,f))
2214 {
2215 return qe_invalid;
2216 }
2217
2218
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if (version > V_HEADER)
2219 return qe_version;
2220
2221 796 FFCore.quest_format[vHeader] = version;
2222
2223
2/4
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 796 times.
✗ Branch 3 not taken.
796 if(!p_igetw(&dummy,f))
2224 {
2225 return qe_invalid;
2226 }
2227
2228 //section size
2229
2/4
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 796 times.
✗ Branch 3 not taken.
796 if(!p_igetl(&dummy,f))
2230 {
2231 return qe_invalid;
2232 }
2233
2234 //finally... section data
2235
2/4
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 796 times.
✗ Branch 3 not taken.
796 if(!p_igetw(&tempheader.zelda_version,f))
2236 {
2237 return qe_invalid;
2238 }
2239
2240 796 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2241
2242 //do some quick checking...
2243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 796 times.
796 if(tempheader.zelda_version > ZELDA_VERSION)
2244 {
2245 return qe_version;
2246 }
2247
2248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 796 times.
796 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2249 {
2250 return qe_invalid;
2251 }
2252
2253
2/4
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 796 times.
✗ Branch 3 not taken.
796 if(bad_version(tempheader.zelda_version))
2254 {
2255 return qe_obsolete;
2256 }
2257
2258
2/4
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 796 times.
✗ Branch 3 not taken.
796 if(!p_getc(&tempheader.build,f))
2259 {
2260 return qe_invalid;
2261 }
2262
2263 796 FFCore.quest_format[vBuild] = tempheader.build;
2264
2265
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 737 times.
796 if(version<3)
2266 {
2267
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!pfread(temp_pwd,30,f))
2268 {
2269 return qe_invalid;
2270 }
2271
2272
2/4
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
59 if(!p_igetw(&temp_pwdkey,f))
2273 {
2274 return qe_invalid;
2275 }
2276
2277 59 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2278
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Init(&ctx);
2279
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2280
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2281 59 }
2282 else
2283 {
2284
2/4
✓ Branch 0 taken 737 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 737 times.
✗ Branch 3 not taken.
737 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2285 {
2286 return qe_invalid;
2287 }
2288 }
2289
2290
2/4
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 796 times.
✗ Branch 3 not taken.
796 if(!p_igetw(&tempheader.internal,f))
2291 {
2292 return qe_invalid;
2293 }
2294
2295
2/4
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 796 times.
✗ Branch 3 not taken.
796 if(!p_getc(&tempheader.quest_number,f))
2296 {
2297 return qe_invalid;
2298 }
2299
2300 796 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2301
2302 796 size_t versz = version < 8 ? 9 : 16;
2303
2/4
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 796 times.
✗ Branch 3 not taken.
796 if(!pfread(tempheader.version,versz,f))
2304 {
2305 return qe_invalid;
2306 }
2307
2308 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2309 //needs to be copied as char[9] or stored as a s.str
2310
2/4
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 796 times.
✗ Branch 3 not taken.
796 if(!pfread(tempheader.minver,versz,f))
2311 {
2312 return qe_invalid;
2313 }
2314
2315 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2316
2/4
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 796 times.
✗ Branch 3 not taken.
796 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2317 {
2318 return qe_invalid;
2319 }
2320 796 tempheader.title[sizeof(tempheader.title)-1] = 0;
2321
2322
2/4
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 796 times.
✗ Branch 3 not taken.
796 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2323 {
2324 return qe_invalid;
2325 }
2326 796 tempheader.author[sizeof(tempheader.author)-1] = 0;
2327
2328
2/4
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 796 times.
✗ Branch 3 not taken.
796 if(!p_getc(&tempheader.use_keyfile,f))
2329 {
2330 return qe_invalid;
2331 }
2332
2333 /*
2334 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2335 {
2336 return qe_invalid;
2337 }
2338 */
2339
2/4
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 796 times.
✗ Branch 3 not taken.
796 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2340 {
2341 return qe_invalid;
2342 }
2343
2344
2/4
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 796 times.
✗ Branch 3 not taken.
796 if(!pfread(&dummybuf,4,f))
2345 {
2346 return qe_invalid;
2347 }
2348
2349
2/4
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 796 times.
✗ Branch 3 not taken.
796 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2350 {
2351 return qe_invalid;
2352 }
2353
2354
2/4
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 796 times.
✗ Branch 3 not taken.
796 if(!pfread(dummybuf,14,f))
2355 {
2356 return qe_invalid;
2357 }
2358
2359 796 templatepath_len=sizeof(tempheader.templatepath);
2360
2361
2/2
✓ Branch 0 taken 737 times.
✓ Branch 1 taken 59 times.
796 if(version==1)
2362 {
2363 59 templatepath_len=280;
2364 59 }
2365
2366
2/4
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 796 times.
✗ Branch 3 not taken.
796 if(!pfread(tempheader.templatepath,templatepath_len,f))
2367 {
2368 return qe_invalid;
2369 }
2370
2371
2/4
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 796 times.
✗ Branch 3 not taken.
796 if(!p_getc(&temp_map_count,f))
2372 {
2373 return qe_invalid;
2374 }
2375
2376
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 588 times.
796 if(version>=4)
2377 {
2378
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_igetl(&tempheader.version_major,f))
2379 {
2380 return qe_invalid;
2381 }
2382
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_igetl(&tempheader.version_minor,f))
2383 {
2384 return qe_invalid;
2385 }
2386
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_igetl(&tempheader.version_patch,f))
2387 {
2388 return qe_invalid;
2389 }
2390
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2391 {
2392 return qe_invalid;
2393 }
2394
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2395 {
2396 return qe_invalid;
2397 }
2398
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_igetl(&tempheader.new_version_id_beta,f))
2399 {
2400 return qe_invalid;
2401 }
2402
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2403 {
2404 return qe_invalid;
2405 }
2406
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_igetl(&tempheader.new_version_id_release,f))
2407 {
2408 return qe_invalid;
2409 }
2410
2411 // 2.55 alpha 86 incorrectly used 56 as the second version component. Fix that here.
2412
3/6
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 164 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
208 if (tempheader.version_major == 2 && tempheader.version_minor == 56 && tempheader.new_version_id_alpha == 86)
2413 tempheader.version_minor = 55;
2414
2415
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2416 {
2417 return qe_invalid;
2418 }
2419
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_getc(&tempheader.new_version_id_date_month,f))
2420 {
2421 return qe_invalid;
2422 }
2423
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_getc(&tempheader.new_version_id_date_day,f))
2424 {
2425 return qe_invalid;
2426 }
2427
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2428 {
2429 return qe_invalid;
2430 }
2431
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2432 {
2433 return qe_invalid;
2434 }
2435
2436
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!pfread(tempheader.new_version_devsig,256,f))
2437 {
2438 return qe_invalid;
2439 }
2440
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2441 strcpy(tempheader.new_version_devsig, "EmilyV99");
2442
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!pfread(tempheader.new_version_compilername,256,f))
2443 {
2444 return qe_invalid;
2445 }
2446
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!pfread(tempheader.new_version_compilerversion,256,f))
2447 {
2448 return qe_invalid;
2449 }
2450
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!pfread(tempheader.product_name,1024,f))
2451 {
2452 return qe_invalid;
2453 }
2454
2455
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_getc(&tempheader.compilerid,f))
2456 {
2457 return qe_invalid;
2458 }
2459
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2460 {
2461 return qe_invalid;
2462 }
2463
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2464 {
2465 return qe_invalid;
2466 }
2467
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2468 {
2469 return qe_invalid;
2470 }
2471
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2472 {
2473 return qe_invalid;
2474 }
2475
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_igetw(&tempheader.developerid,f))
2476 {
2477 return qe_invalid;
2478 }
2479
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!pfread(tempheader.made_in_module_name,1024,f))
2480 {
2481 return qe_invalid;
2482 }
2483
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!pfread(tempheader.build_datestamp,256,f))
2484 {
2485 return qe_invalid;
2486 }
2487
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!pfread(tempheader.build_timestamp,256,f))
2488 {
2489 return qe_invalid;
2490 }
2491 208 }
2492 else // <4
2493 {
2494 588 tempheader.version_major = 0;
2495 588 tempheader.version_minor = 0;
2496 588 tempheader.version_patch = 0;
2497 588 tempheader.new_version_id_fourth = 0;
2498 588 tempheader.new_version_id_alpha = 0;
2499 588 tempheader.new_version_id_beta = 0;
2500 588 tempheader.new_version_id_gamma = 0;
2501 588 tempheader.new_version_id_release = 0;
2502 588 tempheader.new_version_id_date_year = 0;
2503 588 tempheader.new_version_id_date_month = 0;
2504 588 tempheader.new_version_id_date_day = 0;
2505 588 tempheader.new_version_id_date_hour = 0;
2506 588 tempheader.new_version_id_date_minute = 0;
2507
2508 588 memset(tempheader.new_version_devsig, 0, 256);
2509 588 memset(tempheader.new_version_compilername, 0, 256);
2510 588 memset(tempheader.new_version_compilerversion, 0, 256);
2511 588 memset(tempheader.product_name, 0, 1024);
2512 588 strcpy(tempheader.product_name, "ZQuest Classic");
2513
2514 588 tempheader.compilerid = 0;
2515 588 tempheader.compilerversionnumber_first = 0;
2516 588 tempheader.compilerversionnumber_second = 0;
2517 588 tempheader.compilerversionnumber_third = 0;
2518 588 tempheader.compilerversionnumber_fourth = 0;
2519 588 tempheader.developerid = 0;
2520
2521 588 memset(tempheader.made_in_module_name, 0, 1024);
2522 588 memset(tempheader.build_datestamp, 0, 256);
2523 588 memset(tempheader.build_timestamp, 0, 256);
2524 }
2525
2526
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 588 times.
796 if ( version >= 5 )
2527 {
2528
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!pfread(tempheader.build_timezone,6,f))
2529 {
2530 return qe_invalid;
2531 }
2532 208 }
2533 else // < 5
2534 {
2535 588 memset(tempheader.build_timezone, 0, 6);
2536 }
2537
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 588 times.
796 if ( version >= 6 )
2538 {
2539 byte b;
2540
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_getc(&b,f))
2541 {
2542 return qe_invalid;
2543 }
2544 208 tempheader.external_zinfo = b?true:false;
2545 208 read_zinfo = true;
2546 208 }
2547
2548
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 588 times.
796 if(version >= 7)
2549 {
2550
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2551 {
2552 return qe_invalid;
2553 }
2554 208 }
2555 else
2556 {
2557 588 tempheader.new_version_is_nightly = false;
2558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 588 times.
588 if(tempheader.zelda_version < 0x255)
2559 {
2560
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 529 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 59 times.
588 switch(tempheader.zelda_version)
2561 {
2562 case 0x254:
2563 tempheader.version_major = 2;
2564 tempheader.version_minor = 54;
2565 break;
2566 case 0x250:
2567
7/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 31 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 410 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 29 times.
✓ Branch 15 taken 13 times.
529 switch(tempheader.build)
2568 {
2569 case 19:
2570 tempheader.version_major = 2;
2571 tempheader.version_minor = 50;
2572 tempheader.new_version_id_gamma = 1;
2573 break;
2574 case 20:
2575 tempheader.version_major = 2;
2576 tempheader.version_minor = 50;
2577 tempheader.new_version_id_gamma = 2;
2578 break;
2579 case 21:
2580 tempheader.version_major = 2;
2581 tempheader.version_minor = 50;
2582 tempheader.new_version_id_gamma = 3;
2583 break;
2584 case 22:
2585 tempheader.version_major = 2;
2586 tempheader.version_minor = 50;
2587 tempheader.new_version_id_gamma = 4;
2588 break;
2589 case 23:
2590 tempheader.version_major = 2;
2591 tempheader.version_minor = 50;
2592 tempheader.new_version_id_gamma = 5;
2593 break;
2594 case 24:
2595 31 tempheader.version_major = 2;
2596 31 tempheader.version_minor = 50;
2597 31 tempheader.new_version_id_release = -1;
2598 31 break;
2599 case 25:
2600 tempheader.version_major = 2;
2601 tempheader.version_minor = 50;
2602 tempheader.version_patch = 1;
2603 tempheader.new_version_id_gamma = 1;
2604 break;
2605 case 26:
2606 24 tempheader.version_major = 2;
2607 24 tempheader.version_minor = 50;
2608 24 tempheader.version_patch = 1;
2609 24 tempheader.new_version_id_gamma = 2;
2610 24 break;
2611 case 27:
2612 tempheader.version_major = 2;
2613 tempheader.version_minor = 50;
2614 tempheader.version_patch = 1;
2615 tempheader.new_version_id_gamma = 3;
2616 break;
2617 case 28:
2618 6 tempheader.version_major = 2;
2619 6 tempheader.version_minor = 50;
2620 6 tempheader.version_patch = 1;
2621 6 tempheader.new_version_id_release = -1;
2622 6 break;
2623 case 29:
2624 410 tempheader.version_major = 2;
2625 410 tempheader.version_minor = 50;
2626 410 tempheader.version_patch = 2;
2627 410 tempheader.new_version_id_release = -1;
2628 410 break;
2629 case 30:
2630 tempheader.version_major = 2;
2631 tempheader.version_minor = 50;
2632 tempheader.version_patch = 3;
2633 tempheader.new_version_id_gamma = 1;
2634 break;
2635 case 31:
2636 16 tempheader.version_major = 2;
2637 16 tempheader.version_minor = 53;
2638 16 tempheader.new_version_id_gamma = -1;
2639 16 break;
2640 case 32:
2641 29 tempheader.version_major = 2;
2642 29 tempheader.version_minor = 53;
2643 29 tempheader.new_version_id_release = -1;
2644 29 break;
2645 case 33:
2646 13 tempheader.version_major = 2;
2647 13 tempheader.version_minor = 53;
2648 13 tempheader.version_patch = 1;
2649 13 break;
2650 }
2651 529 break;
2652
2653 case 0x211:
2654 tempheader.version_major = 2;
2655 tempheader.version_minor = 11;
2656 tempheader.new_version_id_beta = tempheader.build;
2657 break;
2658 case 0x210:
2659 59 tempheader.version_major = 2;
2660 59 tempheader.version_minor = 10;
2661 59 tempheader.new_version_id_beta = tempheader.build;
2662 59 break;
2663 }
2664 588 }
2665 }
2666
2667
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 632 times.
796 if (version>=9)
2668 {
2669 164 std::string version_string;
2670
2/4
✓ Branch 0 taken 164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 164 times.
✗ Branch 3 not taken.
164 if(!p_getcstr(&version_string, f))
2671 {
2672 return qe_invalid;
2673 }
2674
2675 164 strncpy(tempheader.zelda_version_string, version_string.c_str(), sizeof(tempheader.zelda_version_string));
2676 164 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%s", version_string.c_str());
2677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 164 times.
164 }
2678 else
2679 {
2680 632 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%d.%d.%d", tempheader.version_major, tempheader.version_minor, tempheader.version_patch);
2681 }
2682 }
2683
2684
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 762 times.
820 if(printmetadata)
2685 {
2686
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2687 58 }
2688
2689 //{ Version Warning
2690
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 int32_t vercmp = tempheader.compareVer();
2691
3/6
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 820 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 820 times.
✗ Branch 5 not taken.
820 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), getAlphaState());
2692
2/4
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 820 times.
✗ Branch 3 not taken.
820 int32_t avercmp = compare(tempheader.getAlphaVer(), 0);
2693
4/6
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 656 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 164 times.
984 if(vercmp > 0 || (!vercmp &&
2694
2/4
✓ Branch 0 taken 164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 164 times.
✗ Branch 3 not taken.
164 (astatecmp > 0 || (!astatecmp &&
2695 164 avercmp > 0))))
2696 {
2697 bool r = true;
2698 if(loadquest_report)
2699 {
2700 enter_sys_pal();
2701 AlertDialog("Quest saved in newer version",
2702 "This quest was last saved in a newer version of ZQuest."
2703 " Attempting to load this quest may not work correctly; to"
2704 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2705 "\n\nWould you like to continue loading anyway? (Not recommended)",
2706 [&](bool ret,bool)
2707 {
2708 r = ret;
2709 }).show();
2710 exit_sys_pal();
2711 }
2712 if(!r)
2713 return qe_silenterr;
2714 }
2715 //}
2716
2717 820 read_ext_zinfo = tempheader.external_zinfo;
2718
2719
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 *Header = tempheader;
2720 820 map_count=temp_map_count;
2721 820 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2722
2723
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 unpack_qrs();
2724
2725 820 return 0;
2726 844 }
2727
2728 11204 int32_t readrules(PACKFILE *f, zquestheader *Header)
2729 {
2730
2/2
✓ Branch 0 taken 11181 times.
✓ Branch 1 taken 23 times.
11204 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_rules);
2731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11204 times.
11204 if (should_skip)
2732 return 0;
2733
2734 int32_t dummy;
2735 11204 zquestheader tempheader = *Header;
2736 11204 word s_version=0;
2737 11204 dword compatrule_version=0;
2738
2739
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 10737 times.
11204 if(tempheader.zelda_version >= 0x193)
2740 {
2741 //section version info
2742
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
467 if(!p_igetw(&s_version,f))
2743 {
2744 return qe_invalid;
2745 }
2746
2747
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if (s_version > V_RULES)
2748 return qe_version;
2749
2750 467 FFCore.quest_format[vRules] = s_version;
2751
2752
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
467 if(!p_igetw(&dummy,f))
2753 {
2754 return qe_invalid;
2755 }
2756
2757
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 259 times.
467 if(s_version > 16)
2758 {
2759
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!p_igetl(&compatrule_version,f))
2760 {
2761 return qe_invalid;
2762 }
2763 208 }
2764 467 FFCore.quest_format[vCompatRule] = compatrule_version;
2765
2766 //section size
2767
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
467 if(!p_igetl(&dummy,f))
2768 {
2769 return qe_invalid;
2770 }
2771
2772
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 208 times.
467 if ( s_version < 15 )
2773 {
2774 //finally... section data
2775
2/4
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 259 times.
✗ Branch 3 not taken.
259 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
2776 {
2777 return qe_invalid;
2778 }
2779 259 }
2780 else
2781 {
2782
2783
2/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
2784 {
2785 return qe_invalid;
2786 }
2787
2788 }
2789 467 }
2790
2791 //{ bunch of compat stuff
2792 11204 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2793
2794
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 10714 times.
11204 unpack_qrs();
2795
2796
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 408 times.
490 if(s_version<2)
2797 {
2798
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(14,0);
2799
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
2800
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(28,0);
2801
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(29,0);
2802
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(30,0);
2803
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(32,0);
2804
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(36,0);
2805
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(49,0);
2806
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(50,0);
2807
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(51,0);
2808
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(68,0);
2809
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(75,0);
2810
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(76,0);
2811
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(98,0);
2812
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(110,0);
2813
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(113,0);
2814
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(116,0);
2815
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(102,0);
2816
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(132,0);
2817 82 }
2818
2819 //Now, do any updates...
2820
3/4
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 408 times.
490 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
2821 {
2822
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
2823
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_REPLACEOPENDOORS, 1);
2824
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDLENSORDER, 1);
2825
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOFAIRYGUYFIRES, 1);
2826
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_TRIGGERSREPEAT, 1);
2827 82 }
2828
2829
3/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 467 times.
490 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2830 {
2831
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_WALLFLIERS,1);
2832 23 }
2833
2834
3/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 467 times.
490 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
2835 {
2836
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOBOMBPALFLASH,1);
2837 23 }
2838
2839
3/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 467 times.
490 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2840 {
2841
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_NOSCROLLCONTINUE,1);
2842 23 }
2843
2844
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 408 times.
490 if(tempheader.zelda_version <= 0x210)
2845 {
2846
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ARROWCLIP,1);
2847 82 }
2848
2849
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 431 times.
490 if(tempheader.zelda_version == 0x210)
2850 {
2851
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
2852
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CMBCYCLELAYERS, 0);
2853
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
2854 59 }
2855
2856
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 408 times.
490 if(tempheader.zelda_version <= 0x210)
2857 {
2858
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLDSTYLEWARP,1);
2859
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_210_WARPRETURN,1);
2860 82 }
2861
2862 //might not be correct
2863
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 467 times.
490 if(tempheader.zelda_version < 0x210)
2864 {
2865
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
2866
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDTRIBBLES_DEP,1);
2867
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLDHOOKSHOTGRAB,1);
2868 23 }
2869
2870
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 408 times.
490 if(tempheader.zelda_version < 0x211)
2871 {
2872
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
2873 82 }
2874
2875
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 485 times.
490 if((tempheader.zelda_version == 0x192 && tempheader.build <= 163) || tempheader.zelda_version < 0x192)
2876 {
2877
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 468 times.
490 set_qr(qr_192b163_WARP,1);
2878 22 }
2879
2880
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 37 times.
22 if(tempheader.zelda_version == 0x210)
2881 {
2882
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2883
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
2884
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 set_qr(qr_DMGCOMBOPRI, 0);
2885 59 }
2886
2887
3/4
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 408 times.
96 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
2888 {
2889
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 230 times.
312 set_qr(qr_OLDPICKUP,1);
2890 82 }
2891
2892
3/4
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 408 times.
490 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
2893 {
2894
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
2895
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
2896 82 }
2897
2898
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 408 times.
490 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
2899 {
2900
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOOKSHOTDOWNBUG, 1);
2901 82 }
2902
2903
4/4
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 290 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 169 times.
490 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
2904 {
2905
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 set_qr(qr_PEAHATCLOCKVULN, 1);
2906 31 }
2907
2908
4/4
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 208 times.
490 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
2909 {
2910
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 200 times.
282 set_qr(qr_OLD_DOORREPAIR, 1);
2911 82 }
2912
2913
4/4
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 118 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 208 times.
290 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
2914 {
2915
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 236 times.
318 set_qr(qr_OLD_SECRETMONEY, 1);
2916 82 }
2917
2918
4/4
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 118 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 208 times.
290 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
2919 {
2920
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 181 times.
318 set_qr(qr_OLD_POTION_OR_HC, 1);
2921 137 }
2922
2923
4/4
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 208 times.
345 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
2924 {
2925
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 128 times.
265 set_qr(qr_OFFSCREENWEAPONS, 1);
2926 137 }
2927
2928 //Bombchu fix.
2929
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 200 times.
345 if(tempheader.zelda_version == 0x250)
2930 {
2931
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 169 times.
200 if ( tempheader.build == 24 ) //2.50.0
2932 {
2933
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2934 31 }
2935
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 194 times.
200 if ( tempheader.build == 28 ) //2.50.1
2936 {
2937
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 set_qr(qr_BOMBCHUSUPERBOMB, 1);
2938 6 }
2939
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 119 times.
200 if ( tempheader.build == 29 ) //2.50.2
2940 {
2941
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2942 81 }
2943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if ( tempheader.build == 30 ) //2.50.3RC1
2944 {
2945 set_qr(qr_BOMBCHUSUPERBOMB, 0);
2946 }
2947 200 }
2948
2949
4/4
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 208 times.
345 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
2950 {
2951 // qr_OFFSETEWPNCOLLISIONFIX
2952 // All 'official' quests need this disabled.
2953 // All 2.10 and lower quests need this enabled to preseve compatability.
2954 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
2955
2956 //~Gleeok
2957
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 124 times.
265 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
2958
2959 // Broke in build 695
2960
3/4
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
143 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
2961
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 set_qr(qr_BROKENSTATUES, 1);
2962 143 }
2963
11/14
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 472 times.
✓ Branch 2 taken 467 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 588 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 588 times.
✓ Branch 9 taken 5 times.
✓ Branch 10 taken 22 times.
✓ Branch 11 taken 571 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
351 if (tempheader.zelda_version <= 0x190 || (tempheader.zelda_version == 0x192 && std::string(tempheader.title).starts_with("Zelda 3000\0")))
2964 {
2965
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 set_qr(qr_COPIED_SWIM_SPRITES, 1);
2966 22 }
2967
8/8
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 393 times.
✓ Branch 2 taken 303 times.
✓ Branch 3 taken 90 times.
✓ Branch 4 taken 221 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 208 times.
✓ Branch 7 taken 13 times.
593 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
2968 {
2969
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 311 times.
580 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
2970 269 }
2971
2972
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 200 times.
282 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
2973 {
2974
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_OLD_210_WATER, 1);
2975 82 }
2976
2977
4/6
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 208 times.
282 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
2978 {
2979
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 178 times.
104 set_qr(qr_STEP_IS_FLOAT,0);
2980 282 }
2981
2982
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 408 times.
490 if ( tempheader.zelda_version < 0x250 )
2983 {
2984
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_8WAY_SHOT_SFX_DEP, 1);
2985 82 }
2986
2987
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 408 times.
490 if(s_version < 3)
2988 {
2989
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HOLDNOSTOPMUSIC, 1);
2990
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
2991 82 }
2992
2993
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 408 times.
490 if(s_version<4)
2994 {
2995
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(10,0);
2996 82 }
2997
2998
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 408 times.
490 if(s_version<5)
2999 {
3000
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(27,0);
3001 82 }
3002
3003
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 408 times.
490 if(s_version<6)
3004 {
3005
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(46,0);
3006 82 }
3007
3008
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 408 times.
490 if(s_version<7) // January 2008
3009 {
3010
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_HEARTSREQUIREDFIX,0);
3011
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PUSHBLOCKCSETFIX,1);
3012 82 }
3013
3014
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 408 times.
490 if(s_version<8)
3015 {
3016
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(12, 0);
3017 82 }
3018 else
3019 {
3020
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 set_bit(deprecated_rules, 12, 0);
3021 }
3022
3023
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 408 times.
490 if(s_version<9) // October 2008
3024 {
3025
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOROPE2FLASH_DEP,0);
3026
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3027
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_GHINI2BLINK_DEP,0);
3028
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_PHANTOMGHINI2_DEP,0);
3029 82 }
3030
3031
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 408 times.
490 if(s_version<10) // December 2008
3032 {
3033
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_NOCLOCKS_DEP,0);
3034
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3035 82 }
3036
3037
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 408 times.
490 if(s_version<11) // April 2009
3038 {
3039
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SLOWENEMYANIM_DEP,0);
3040 82 }
3041
3042 // This served no purpose.
3043 // if(s_version<12) // December 2009
3044 // {
3045 // set_qr(qr_BRKBLSHLDS_DEP,0);
3046 // set_qr(qr_OLDTRIBBLES_DEP,0);
3047 // }
3048
3049 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3050
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 408 times.
490 if(s_version < 13)
3051 {
3052
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SHOPCHEAT, 1);
3053 82 }
3054
3055 // Not entirely sure this is the best place for this...
3056 //2.50.2 bitmap offset fix
3057 490 memset(extra_rules, 0, EXTRARULES_SIZE);
3058
4/4
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 208 times.
490 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3059 {
3060
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 139 times.
282 set_er(er_BITMAPOFFSET, 1);
3061
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 set_qr(qr_BITMAPOFFSETFIX, 1);
3062 143 }
3063 //required because quest templates also used this bit, although
3064 //it never did anything, before. -Z
3065
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 151 times.
351 if ( tempheader.zelda_version == 0x250 )
3066 {
3067
5/6
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 103 times.
200 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3068 {
3069
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 set_er(er_BITMAPOFFSET, 0);
3070
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 set_qr(qr_BITMAPOFFSETFIX, 0);
3071 97 }
3072 200 }
3073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 351 times.
351 if ( tempheader.zelda_version == 0x254 )
3074 {
3075 set_er(er_BITMAPOFFSET, 0);
3076 set_qr(qr_BITMAPOFFSETFIX, 0);
3077 }
3078
3/4
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 143 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 208 times.
351 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3079 {
3080 set_er(er_BITMAPOFFSET, 0);
3081 set_qr(qr_BITMAPOFFSETFIX, 0);
3082 }
3083 //optimise fast drawing for older versions.
3084
3/4
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 143 times.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
351 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3085 {
3086
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 103 times.
351 set_qr(qr_OLDSPRITEDRAWS, 1);
3087 282 }
3088 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3089 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3090 //older quests can set the rule by hand. We need a new qst.dat again.
3091
4/4
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 208 times.
✓ Branch 2 taken 208 times.
✓ Branch 3 taken 282 times.
282 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3092 {
3093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 416 times.
416 set_qr(qr_OLDEWPNPARENT, 1);
3094 }
3095
4/4
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 208 times.
✓ Branch 2 taken 208 times.
✓ Branch 3 taken 282 times.
282 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3096 {
3097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 416 times.
416 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3098 }
3099
4/4
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 208 times.
✓ Branch 2 taken 208 times.
✓ Branch 3 taken 282 times.
282 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3100 {
3101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 416 times.
416 set_qr(qr_OLDQUESTMISC, 1);
3102 }
3103
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if ( tempheader.zelda_version < 0x254 )
3104 {
3105
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3106
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDEWPNPARENT, 0);
3107
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDQUESTMISC, 0);
3108 282 }
3109
3110 //item scripts continue to run
3111
3/4
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3112 {
3113
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 30 times.
312 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3114
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3115
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3116
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3117
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3118
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3119
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3120 282 }
3121
3122
3/4
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3123 {
3124
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 30 times.
312 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3125 282 }
3126
3/4
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3127 {
3128
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 30 times.
312 set_qr(qr_TRACESCRIPTIDS, 0);
3129
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3130
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3131
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_250DIVISION,1);
3132
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3133
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3134
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_FORCE_INLINE,0);
3135
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PARSER_BINARY_32BIT,0);
3136
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 274 times.
282 if ( get_qr(qr_SELECTAWPN) )
3137 {
3138
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3139 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3140 //Now they **do**, unless you disable that behaviour.
3141 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3142 //now enable the disable L/R item swap on load.
3143 8 }
3144
3145 282 }
3146
3/4
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3147 {
3148 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3149
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 30 times.
312 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3150 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3151 //animations ending earlier than they should.
3152
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3153 //Enemies would ignore solidity on the top half of combos
3154
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3155 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3156
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3157 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3158
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3159 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3160
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3161 282 }
3162
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if ( tempheader.zelda_version < 0x255 )
3163 {
3164
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_NOFFCWAITDRAW, 1);
3165
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_NOITEMWAITDRAW, 1);
3166
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3167
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3168 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3169 282 }
3170
3/4
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3171 {
3172
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 30 times.
312 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3173 282 }
3174
3/4
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
282 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3175 {
3176
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 30 times.
312 set_qr(qr_OLD_PRINTF_ARGS, 1);
3177 282 }
3178
3179
3180
3/4
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3181 {
3182
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 30 times.
312 set_qr(qr_BROKEN_RING_POWER, 1);
3183 282 }
3184
3/4
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3185 {
3186
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 30 times.
312 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3187 282 }
3188
5/6
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 178 times.
✓ Branch 5 taken 30 times.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3189 {
3190
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3191 282 }
3192
3/4
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
312 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3193 {
3194 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
312 if(get_qr(qr_SET_XBUTTON_ITEMS))
3196 set_qr(qr_SET_YBUTTON_ITEMS,1);
3197 282 }
3198
3/4
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3199 {
3200
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 30 times.
312 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3201 282 }
3202
3/4
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3203 {
3204
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 30 times.
312 set_qr(qr_OLD_CHEST_COLLISION,1);
3205 282 }
3206
3207
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if ( tempheader.zelda_version < 0x254 )
3208 {
3209
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3210 282 }
3211 //Sideview spikes in 2.50.0
3212
4/4
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 208 times.
282 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3213 {
3214
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 189 times.
326 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3215 137 }
3216 //more 2.50 fixes -Z
3217
4/4
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 208 times.
345 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3218 {
3219
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 63 times.
265 set_qr(qr_MELEEMAGICCOST, 0);
3220
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3221
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_OLDMIRRORCOMBOS, 1);
3222
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_BROKENBOOKCOST, 1);
3223
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 set_qr(qr_BROKENCHARINTDRAWING, 1);
3224
3225 224 }
3226
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 432 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
432 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3227 {
3228 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3229 set_qr(qr_MELEEMAGICCOST, 1);
3230 }
3231
3232
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 409 times.
432 if(tempheader.zelda_version < 0x193)
3233 {
3234
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_SHORTDGNWALK, 1);
3235 23 }
3236
3237
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 150 times.
432 if(tempheader.zelda_version < 0x255)
3238 {
3239
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDINFMAGIC, 1);
3240 282 }
3241
3242
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 350 times.
432 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Hero out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3243 {
3244
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3245 82 }
3246
3247
3/4
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
432 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3248 {
3249
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 150 times.
432 set_qr(qr_OLD_F6,1);
3250 282 }
3251
3/4
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3252 {
3253
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 30 times.
312 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3254 282 }
3255
3/4
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3256 {
3257
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 30 times.
312 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3258 282 }
3259
3/4
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
282 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3260 {
3261
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 30 times.
312 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3262 282 }
3263 //}
3264
3265
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3266
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3267
3268
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 2) //Old CSet2 Handling
3269
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLDCS2,1);
3270
3271
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3272
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3273
3274
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3275
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3276
3277
3/4
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 82 times.
282 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3278
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3279
3280
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3281
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3282
3283
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3284
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3285
3286
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3287
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3288
3289
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 9)
3290 {
3291 //Hardcoded BS Patras
3292
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_HARDCODED_BS_PATRA,1);
3293 //Hardcoded Patra Inner Eye offsets
3294
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3295 //Broken 'Big enemy' animation style
3296
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3297 //Broken Attribute 31/32
3298
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3299 282 }
3300
3301
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 10) //Shared candle use limits
3302
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3303
3304
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 11) //No cross-screen return points
3305
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_RESPAWN_POINTS,1);
3306
3307
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 12)
3308 {
3309 //Old fire trail duration
3310
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3311 //Old Intro String in Ganon Room Behavior
3312
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3313
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 else set_qr(qr_GANONINTRO,1);
3314 282 }
3315
3316
2/4
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 282 times.
282 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3317 set_qr(qr_ANONE_NOANIM,1);
3318
3319
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 14) //Old Bridge Combo Behavior
3320
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3321
3322
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 15) //Broken Z3 Animation
3323
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3324
3325
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3326
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3327
3328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
282 if(compatrule_version < 17)
3329 {
3330 //Old Quake/DrawYOffset behavior
3331 //set_qr(qr_OLD_DRAWOFFSET,1);
3332 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3333 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3334 282 }
3335
3336
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 18)
3337 {
3338 //Broken DrawScreen Derivative Functions
3339
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3340 //Scrolling Cancels Charge
3341
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3342 282 }
3343
3344
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3345
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3346
3347
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 20)
3348
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3349
3350
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 21)
3351 {
3352
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3353
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3354
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3355
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_BUG_NET,1);
3356
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3357 282 }
3358
3359
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 22)
3360
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3361
3362
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 23)
3363
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_HALF_MAGIC,1);
3364
3365
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 24)
3366 {
3367
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3368
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3369 282 }
3370
3371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
282 if(compatrule_version < 25)
3372 {
3373
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3374
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3375
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3376 282 }
3377
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 if(compatrule_version < 26)
3378 {
3379
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3380
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_POLVIRE_NO_SHADOW,1);
3381
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3382 282 }
3383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
282 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3384 {
3385
2/2
✓ Branch 0 taken 84882 times.
✓ Branch 1 taken 282 times.
85164 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3386
1/2
✓ Branch 0 taken 84882 times.
✗ Branch 1 not taken.
84882 set_qr(q,0);
3387
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 282 times.
1974 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < qr_MAX; ++q)
3388
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 set_qr(q,0);
3389 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3390 282 }
3391
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
282 if(compatrule_version < 28)
3392
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3393
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 29)
3394
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3395
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 30)
3396 {
3397
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_DECO_2_YOFFSET,1);
3398
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_SCREENSTATE_80s_BUG,1);
3399 287 }
3400
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 31)
3401 {
3402
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3403
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3404 287 }
3405
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 32)
3406
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3407
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 33)
3408
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_NO_LIFT_SPRITE,1);
3409
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 34)
3410 {
3411
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3412
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3413
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3414
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3415 287 }
3416
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 3 times.
292 if(compatrule_version < 35)
3417 {
3418
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3419
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3420 289 }
3421
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 3 times.
292 if(compatrule_version < 36)
3422
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 set_qr(qr_OLD_SHALLOW_SFX,1);
3423
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
292 if(compatrule_version < 37)
3424
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3425
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 38)
3426
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3427
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 39)
3428
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3429
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 40)
3430
1/2
✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
293 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3431
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 41)
3432
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_BROKENHITBY,1);
3433
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 42)
3434
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3435
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 43)
3436
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_OLD_BOMB_HITBOXES,1);
3437
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 44)
3438
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3439
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 45)
3440
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3441
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 3 times.
298 if(compatrule_version < 46)
3442
1/2
✓ Branch 0 taken 295 times.
✗ Branch 1 not taken.
295 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3443
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
298 if(compatrule_version < 47)
3444 {
3445
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3446
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3447 299 }
3448
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 48)
3449
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_GUY_HANDLING,1);
3450
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 49)
3451
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3452
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 50)
3453
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3454
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 51)
3455
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3456
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if (compatrule_version < 52)
3457
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3458
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 53)
3459 {
3460
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_SUBSCR,1);
3461
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3462
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3463 299 }
3464
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 54)
3465
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3466
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 55)
3467
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3468
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 56)
3469
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BROKEN_LIGHTBEAM_HITBOX,1);
3470
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 57)
3471
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS,1);
3472
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 58)
3473
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_DMAP_INTRO_STRINGS,1);
3474
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 59)
3475
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SCRIPT_CONTHP_IS_HEARTS,1);
3476
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 60)
3477
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX,1);
3478
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 61)
3479
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_BROKEN_BOMB_AMMO_COSTS,1);
3480
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 5 times.
304 if(compatrule_version < 62)
3481
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 set_qr(qr_OLD_BROKEN_WARPEX_MUSIC,1);
3482
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 4 times.
304 if(compatrule_version < 63)
3483 {
3484
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_LIFTSWIM,1);
3485
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_GENERIC_PUSHBLOCK_LOCKING,1);
3486 300 }
3487
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 4 times.
304 if(compatrule_version < 64)
3488
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 set_qr(qr_BROKEN_FLAME_ARROW_REFLECTING,1);
3489
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 21 times.
304 if(compatrule_version < 65)
3490
1/2
✓ Branch 0 taken 325 times.
✗ Branch 1 not taken.
325 set_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP,1);
3491
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 19 times.
346 if(compatrule_version < 66)
3492
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_NEWDARK_TRANS_STACKING,1);
3493
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 19 times.
346 if(compatrule_version < 67)
3494
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_OLD_HERO_WARP_RETSQUARE,1);
3495
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 19 times.
346 if(compatrule_version < 68)
3496
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_SCRIPTS_6_BIT_COLOR,1);
3497
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 19 times.
346 if(compatrule_version < 69)
3498
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_SETENEMYWEAPONSOUNDSONWPNCHANGE, 1);
3499
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 19 times.
346 if (compatrule_version < 70)
3500
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_BROKEN_CONVEYORS, 1);
3501
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 19 times.
346 if (compatrule_version < 71)
3502
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_BROKEN_PUSHBLOCK_TOP_HALF_SOLIDS, 1);
3503
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 19 times.
346 if (compatrule_version < 72)
3504
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_BROKEN_PUSHBLOCK_FLAG_CLONING, 1);
3505
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 19 times.
346 if (compatrule_version < 73)
3506 {
3507
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_OLD_LANDING_SFX, 1);
3508
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_FIRE_LEVEL_TRIGGERS_ARENT_WEAPONS, 1);
3509 327 }
3510
5/6
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
346 if (compatrule_version < 74 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 9) < 0))
3511
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 326 times.
1 set_qr(qr_BROKEN_SCRIPTS_SCROLLING_HERO_POSITION, 1);
3512
5/6
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 345 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
672 if (compatrule_version < 75 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3513
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 326 times.
1 set_qr(qr_BROKEN_SCRIPTS_BITMAP_DRAW_ORIGIN, 1);
3514
5/6
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 671 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
998 if (compatrule_version < 76 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3515
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 326 times.
1 set_qr(qr_INVERTED_DARK_COMBO_TRIGGERS, 1);
3516
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 997 times.
1324 if (compatrule_version < 77)
3517
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_BROKEN_ICY_FLOOR_SIDEVIEW, 1);
3518
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 997 times.
1324 if (compatrule_version < 78)
3519
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_SCRIPTS_SCREEN_DRAW_LIGHT_NO_OFFSET, 1);
3520
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 997 times.
1324 if (compatrule_version < 79)
3521
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_BROKEN_SYSTEM_COLORS, 1);
3522
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 997 times.
1324 if (compatrule_version < 80)
3523
1/2
✓ Branch 0 taken 327 times.
✗ Branch 1 not taken.
327 set_qr(qr_ZS_OLD_SUSPEND_FFC, 1);
3524
5/6
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 991 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
1324 if (compatrule_version < 81 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 10) < 0))
3525
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 326 times.
7 set_qr(qr_BROKEN_SCROLL_INSTEAD_OF_DROWN_FALL, 1);
3526
5/6
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 1317 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
1650 if (compatrule_version < 81 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 6) < 0))
3527
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 326 times.
7 set_qr(qr_ROPE_ENEMIES_SPEED_NOT_CONFIGURABLE, 1);
3528
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 1643 times.
1976 if (compatrule_version < 82)
3529 {
3530
1/2
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
333 set_qr(qr_EW_ROCKS_HARDCODED_BREAK_ON_SOLID, 1);
3531
1/2
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
333 set_qr(qr_IMPRECISE_WEAPON_SOLIDITY_CHECKS, 1);
3532 333 }
3533
5/6
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 1643 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
1976 if (compatrule_version < 83 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3534
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 326 times.
7 set_qr(qr_BROKEN_BLOCKHOLE_PITFALLS, 1);
3535
5/6
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 1969 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
2302 if (compatrule_version < 84 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3536
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 326 times.
7 set_qr(qr_CUSTOM_WEAPON_BROKEN_SIZE, 1);
3537
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 2294 times.
2628 if (compatrule_version < 85)
3538
1/2
✓ Branch 0 taken 334 times.
✗ Branch 1 not taken.
334 set_qr(qr_OLD_WEAPON_REFLECTION, 1);
3539
5/6
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 2284 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
2628 if (compatrule_version < 86 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3540
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 326 times.
18 set_qr(qr_OLD_SPRITE_FALL_DROWN, 1);
3541
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 2610 times.
2954 if (compatrule_version < 87)
3542
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 set_qr(qr_OLD_TERMINAL_VELOCITY, 1);
3543
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 2610 times.
2954 if (compatrule_version < 88)
3544
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 set_qr(qr_OLD_SCRIPT_LEVEL_GLOBAL_STATES, 1);
3545
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 2610 times.
2954 if (compatrule_version < 89)
3546
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 set_qr(qr_BROKEN_ARMOS_GRAVE_BIGHITBOX_COLLISION, 1);
3547
3548
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 2610 times.
2954 if (compatrule_version < 90)
3549 {
3550
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 set_qr(qr_CLASSIC_DRAWING_ORDER, 1);
3551
1/2
✓ Branch 0 taken 344 times.
✗ Branch 1 not taken.
344 set_qr(qr_OLD_WEAPON_DRAW_ANIMATE_TIMING, 1);
3552 344 }
3553
3554
2/2
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 2608 times.
2954 if (compatrule_version < 91)
3555 {
3556
1/2
✓ Branch 0 taken 346 times.
✗ Branch 1 not taken.
346 set_qr(qr_OLD_SCRIPTS_INTERNAL_ARRAYS_BOUND_INDEX, 1);
3557
1/2
✓ Branch 0 taken 346 times.
✗ Branch 1 not taken.
346 set_qr(qr_OLD_SCRIPTS_ARRAYS_NON_ZERO_DEFAULT_VALUE, 1);
3558 346 }
3559
3560
5/6
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 2556 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 72 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
2954 if (compatrule_version < 92 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 11) < 0))
3561
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 326 times.
72 set_qr(qr_OLD_PIT_SENSITIVITY, 1);
3562
3563
5/6
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 2864 times.
✓ Branch 2 taken 326 times.
✓ Branch 3 taken 90 times.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
3280 if (compatrule_version < 93 && (tempheader.version_major >= 3 || tempheader.compareVer(2, 55, 12) < 0))
3564
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 326 times.
90 set_qr(qr_ACTIVE_SHIELD_PASSIVE_ROC_NO_SCRIPT, 1);
3565
3566
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 3116 times.
3606 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3567
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 208 times.
490 if (s_version < 16)
3568
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3569
3570
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 *Header = tempheader;
3571
3572 490 return 0;
3573 21918 }
3574
3575 4166465 void init_msgstr(MsgStr *str)
3576 {
3577
2/4
✓ Branch 0 taken 4166465 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4166465 times.
4166465 str->setFromLegacyEncoding("");
3578 4166465 str->nextstring=0;
3579 4166465 str->tile=0;
3580 4166465 str->cset=0;
3581 4166465 str->trans=false;
3582 4166465 str->font=font_zfont;
3583 4166465 str->y=32;
3584 4166465 str->sfx=18;
3585 4166465 str->listpos=0;
3586 4166465 str->x=24;
3587 4166465 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3588 4166465 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3589 4166465 str->hspace=0;
3590 4166465 str->vspace=0;
3591 4166465 str->stringflags=0;
3592 4166465 str->margins[up] = 8;
3593 4166465 str->margins[down] = 0;
3594 4166465 str->margins[left] = 8;
3595 4166465 str->margins[right] = 8;
3596 4166465 str->portrait_tile = 0;
3597 4166465 str->portrait_cset = 0;
3598 4166465 str->portrait_x = 0;
3599 4166465 str->portrait_y = 0;
3600 4166465 str->portrait_tw = 1;
3601 4166465 str->portrait_th = 1;
3602 4166465 str->shadow_type = 0;
3603 4166465 str->shadow_color = 0;
3604 4166465 str->drawlayer = 6;
3605 4166465 }
3606
3607 490 void init_msgstrings(int32_t start, int32_t end)
3608 {
3609
2/4
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 490 times.
490 if(end <= start || end-start > msg_strings_size)
3610 return;
3611
3612
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 4014080 times.
4014570 for(int32_t i=start; i<end; i++)
3613 {
3614 4014080 init_msgstr(&MsgStrings[i]);
3615 4014080 MsgStrings[i].listpos=i;
3616 4014080 }
3617
3618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 490 times.
490 if(start==0)
3619 {
3620
2/4
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 490 times.
490 MsgStrings[0].setFromLegacyEncoding("(None)");
3621 490 MsgStrings[0].listpos = 0;
3622 490 }
3623 490 }
3624
3625 491 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3626 {
3627
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 24 times.
491 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_strings);
3628
3629 491 MsgStr tempMsgString;
3630
1/2
✓ Branch 0 taken 491 times.
✗ Branch 1 not taken.
491 init_msgstr(&tempMsgString);
3631
3632 491 word temp_msg_count=0;
3633 word temp_expansion[16];
3634 491 memset(temp_expansion, 0, 16*sizeof(word));
3635 491 char buf[8193] = {0};
3636
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 467 times.
491 if(Header->zelda_version < 0x193)
3637 {
3638 byte tempbyte;
3639 24 int32_t strings_to_read=0;
3640
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3641
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3642
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
3643
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3644 {
3645 18 strings_to_read=128;
3646 18 temp_msg_count=Header->old_str_count;
3647
3648 // Some sort of string count corruption seems to be common in old quests
3649
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(temp_msg_count>128)
3650 {
3651 temp_msg_count=128;
3652 }
3653 18 }
3654
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3655 {
3656 strings_to_read=255;
3657 temp_msg_count=Header->old_str_count;
3658 }
3659 else
3660 {
3661
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetw(&temp_msg_count,f))
3662 {
3663 return qe_invalid;
3664 }
3665
3666 6 strings_to_read=temp_msg_count;
3667
3668
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
6 if (!should_skip && temp_msg_count >= msg_strings_size)
3669 {
3670 Z_message("Reallocating string buffer...\n");
3671
3672 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3673 // return qe_nomem;
3674
3675 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3676 delete[] MsgStrings;
3677 MsgStrings = new MsgStr[MAXMSGS];
3678 msg_strings_size = MAXMSGS;
3679 for(auto q = 0; q < msg_strings_size; ++q)
3680 {
3681 MsgStrings[q].clear();
3682 }
3683 }
3684 }
3685
3686 //reset the message strings
3687
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3688
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 init_msgstrings(0,msg_strings_size);
3689
3690
2/2
✓ Branch 0 taken 2550 times.
✓ Branch 1 taken 24 times.
2574 for(int32_t x=0; x<strings_to_read; x++)
3691 {
3692
1/2
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
2550 init_msgstr(&tempMsgString);
3693 2550 tempMsgString.listpos = x;
3694
3695
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!pfread(buf,73,f))
3696 {
3697 return qe_invalid;
3698 }
3699
3700 2550 buf[74] = '\0';
3701
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 tempMsgString.setFromLegacyEncoding(buf);
3702
3703
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!p_getc(&tempbyte,f))
3704 {
3705 return qe_invalid;
3706 }
3707
3708
3/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 2304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 246 times.
2796 if((Header->zelda_version < 0x192)||
3709
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3710 {
3711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2304 times.
2304 tempMsgString.nextstring=tempbyte?x+1:0;
3712
3713
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3714 {
3715 return qe_invalid;
3716 }
3717
3718
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3719 {
3720 return qe_invalid;
3721 }
3722 2304 }
3723 else
3724 {
3725
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!p_igetw(&tempMsgString.nextstring,f))
3726 {
3727 return qe_invalid;
3728 }
3729
3730
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!pfread(temp_expansion,32,f))
3731 {
3732 return qe_invalid;
3733 }
3734 }
3735
3736
2/2
✓ Branch 0 taken 2549 times.
✓ Branch 1 taken 1 times.
2550 if (!should_skip)
3737 {
3738
1/2
✓ Branch 0 taken 2549 times.
✗ Branch 1 not taken.
2549 MsgStrings[x] = tempMsgString;
3739 2549 }
3740 2550 }
3741 24 }
3742 else
3743 {
3744 int32_t dummy_int;
3745 word s_version;
3746
3747 //section version info
3748
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
467 if(!p_igetw(&s_version,f))
3749 {
3750 return qe_invalid;
3751 }
3752
3753
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if (s_version > V_STRINGS)
3754 return qe_version;
3755
3756 467 FFCore.quest_format[vStrings] = s_version;
3757
3758
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
467 if(!read_deprecated_section_cversion(f))
3759 {
3760 return qe_invalid;
3761 }
3762
3763 //section size
3764
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
467 if(!p_igetl(&dummy_int,f))
3765 {
3766 return qe_invalid;
3767 }
3768
3769 //finally... section data
3770
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
467 if(!p_igetw(&temp_msg_count,f))
3771 {
3772 return qe_invalid;
3773 }
3774
3775
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
467 if(temp_msg_count >= msg_strings_size && !should_skip)
3776 {
3777 Z_message("Reallocating string buffer...\n");
3778
3779 delete[] MsgStrings;
3780 MsgStrings = new MsgStr[MAXMSGS];
3781 msg_strings_size = MAXMSGS;
3782 for(auto q = 0; q < msg_strings_size; ++q)
3783 {
3784 MsgStrings[q].clear();
3785 }
3786 }
3787
3788 //reset the message strings
3789
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 208 times.
467 if(s_version < 7)
3790
1/2
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
259 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3791
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if (!should_skip)
3792
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 init_msgstrings(0,msg_strings_size);
3793
3794 467 int32_t string_length=(s_version<2)?73:145;
3795
3796
2/2
✓ Branch 0 taken 149344 times.
✓ Branch 1 taken 467 times.
149811 for(int32_t i=0; i<temp_msg_count; i++)
3797 {
3798
1/2
✓ Branch 0 taken 149344 times.
✗ Branch 1 not taken.
149344 init_msgstr(&tempMsgString);
3799 149344 tempMsgString.listpos = i;
3800
2/2
✓ Branch 0 taken 17418 times.
✓ Branch 1 taken 131926 times.
149344 if(s_version > 8)
3801 {
3802
2/4
✓ Branch 0 taken 17418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17418 times.
✗ Branch 3 not taken.
17418 if(!p_igetl(&string_length,f))
3803 {
3804 return qe_invalid;
3805 }
3806 17418 }
3807
3808
2/4
✓ Branch 0 taken 149344 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 149344 times.
149344 if (string_length < 0 || string_length > 8193)
3809 {
3810 return qe_invalid;
3811 }
3812
3813
2/2
✓ Branch 0 taken 144472 times.
✓ Branch 1 taken 4872 times.
149344 if (string_length > 0)
3814 {
3815
2/4
✓ Branch 0 taken 144472 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 144472 times.
✗ Branch 3 not taken.
144472 if (!pfread(buf, string_length, f))
3816 {
3817 return qe_invalid;
3818 }
3819 144472 }
3820 else
3821 {
3822 4872 buf[0] = 0;
3823 }
3824
3825
2/4
✓ Branch 0 taken 149344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149344 times.
✗ Branch 3 not taken.
149344 if(!p_igetw(&tempMsgString.nextstring,f))
3826 {
3827 return qe_invalid;
3828 }
3829
3830
2/2
✓ Branch 0 taken 33613 times.
✓ Branch 1 taken 115731 times.
149344 if(s_version<2)
3831 {
3832 33613 buf[72] = '\0';
3833
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33613 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33613 times.
33613 tempMsgString.setFromLegacyEncoding(buf);
3834 33613 }
3835 else
3836 {
3837 // June 2008: A bug corrupted the last 4 chars of a string.
3838 // Discard these.
3839
1/2
✓ Branch 0 taken 115731 times.
✗ Branch 1 not taken.
115731 if(s_version<3)
3840 {
3841 for(int32_t j=140; j<144; j++)
3842 {
3843 buf[j] = '\0';
3844 }
3845 }
3846
1/2
✓ Branch 0 taken 115731 times.
✗ Branch 1 not taken.
115731 if(string_length > 8192) string_length = 8192;
3847 115731 buf[string_length]='\0'; //Force-terminate
3848
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115731 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 115731 times.
115731 tempMsgString.setFromLegacyEncoding(buf);
3849
3850
2/2
✓ Branch 0 taken 17418 times.
✓ Branch 1 taken 98313 times.
115731 if ( s_version >= 6 )
3851 {
3852
2/4
✓ Branch 0 taken 17418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17418 times.
✗ Branch 3 not taken.
17418 if(!p_igetl(&tempMsgString.tile,f))
3853 {
3854 return qe_invalid;
3855 }
3856 17418 }
3857 else
3858 {
3859
2/4
✓ Branch 0 taken 98313 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98313 times.
✗ Branch 3 not taken.
98313 if(!p_igetw(&tempMsgString.tile,f))
3860 {
3861 return qe_invalid;
3862 }
3863 }
3864
3865
2/4
✓ Branch 0 taken 115731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115731 times.
✗ Branch 3 not taken.
115731 if(!p_getc(&tempMsgString.cset,f))
3866 {
3867 return qe_invalid;
3868 }
3869
3870 byte dummy_char;
3871
3872
2/4
✓ Branch 0 taken 115731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115731 times.
✗ Branch 3 not taken.
115731 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
3873 {
3874 return qe_invalid;
3875 }
3876
3877 115731 tempMsgString.trans=dummy_char!=0;
3878
3879
2/4
✓ Branch 0 taken 115731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115731 times.
✗ Branch 3 not taken.
115731 if(!p_getc(&tempMsgString.font,f))
3880 {
3881 return qe_invalid;
3882 }
3883
3884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115731 times.
115731 if(s_version < 5)
3885 {
3886 if(!p_getc(&tempMsgString.y,f))
3887 {
3888 return qe_invalid;
3889 }
3890 }
3891 else
3892 {
3893
2/4
✓ Branch 0 taken 115731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115731 times.
✗ Branch 3 not taken.
115731 if(!p_igetw(&tempMsgString.x,f))
3894 {
3895 return qe_invalid;
3896 }
3897
3898
2/4
✓ Branch 0 taken 115731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115731 times.
✗ Branch 3 not taken.
115731 if(!p_igetw(&tempMsgString.y,f))
3899 {
3900 return qe_invalid;
3901 }
3902
3903
2/4
✓ Branch 0 taken 115731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115731 times.
✗ Branch 3 not taken.
115731 if(!p_igetw(&tempMsgString.w,f))
3904 {
3905 return qe_invalid;
3906 }
3907
3908
2/4
✓ Branch 0 taken 115731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115731 times.
✗ Branch 3 not taken.
115731 if(!p_igetw(&tempMsgString.h,f))
3909 {
3910 return qe_invalid;
3911 }
3912
3913
2/4
✓ Branch 0 taken 115731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115731 times.
✗ Branch 3 not taken.
115731 if(!p_getc(&tempMsgString.hspace,f))
3914 {
3915 return qe_invalid;
3916 }
3917
3918
2/4
✓ Branch 0 taken 115731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115731 times.
✗ Branch 3 not taken.
115731 if(!p_getc(&tempMsgString.vspace,f))
3919 {
3920 return qe_invalid;
3921 }
3922
3923
2/4
✓ Branch 0 taken 115731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115731 times.
✗ Branch 3 not taken.
115731 if(!p_getc(&tempMsgString.stringflags,f))
3924 {
3925 return qe_invalid;
3926 }
3927 }
3928
3929
2/2
✓ Branch 0 taken 98313 times.
✓ Branch 1 taken 17418 times.
115731 if(s_version >= 7)
3930 {
3931
2/2
✓ Branch 0 taken 17418 times.
✓ Branch 1 taken 69672 times.
87090 for(int32_t q = 0; q < 4; ++q)
3932 {
3933
2/4
✓ Branch 0 taken 69672 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69672 times.
✗ Branch 3 not taken.
69672 if(!p_getc(&tempMsgString.margins[q],f))
3934 {
3935 return qe_invalid;
3936 }
3937 69672 }
3938
3939
2/4
✓ Branch 0 taken 17418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17418 times.
✗ Branch 3 not taken.
17418 if(!p_igetl(&tempMsgString.portrait_tile,f))
3940 {
3941 return qe_invalid;
3942 }
3943
3944
2/4
✓ Branch 0 taken 17418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17418 times.
✗ Branch 3 not taken.
17418 if(!p_getc(&tempMsgString.portrait_cset,f))
3945 {
3946 return qe_invalid;
3947 }
3948
3949
2/4
✓ Branch 0 taken 17418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17418 times.
✗ Branch 3 not taken.
17418 if(!p_getc(&tempMsgString.portrait_x,f))
3950 {
3951 return qe_invalid;
3952 }
3953
3954
2/4
✓ Branch 0 taken 17418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17418 times.
✗ Branch 3 not taken.
17418 if(!p_getc(&tempMsgString.portrait_y,f))
3955 {
3956 return qe_invalid;
3957 }
3958
3959
2/4
✓ Branch 0 taken 17418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17418 times.
✗ Branch 3 not taken.
17418 if(!p_getc(&tempMsgString.portrait_tw,f))
3960 {
3961 return qe_invalid;
3962 }
3963
3964
2/4
✓ Branch 0 taken 17418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17418 times.
✗ Branch 3 not taken.
17418 if(!p_getc(&tempMsgString.portrait_th,f))
3965 {
3966 return qe_invalid;
3967 }
3968 17418 }
3969
3970
2/2
✓ Branch 0 taken 17418 times.
✓ Branch 1 taken 98313 times.
115731 if(s_version >= 8)
3971 {
3972
2/4
✓ Branch 0 taken 17418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17418 times.
✗ Branch 3 not taken.
17418 if(!p_getc(&tempMsgString.shadow_type,f))
3973 {
3974 return qe_invalid;
3975 }
3976
3977
2/4
✓ Branch 0 taken 17418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17418 times.
✗ Branch 3 not taken.
17418 if(!p_getc(&tempMsgString.shadow_color,f))
3978 {
3979 return qe_invalid;
3980 }
3981 17418 }
3982
3983
2/2
✓ Branch 0 taken 17109 times.
✓ Branch 1 taken 98622 times.
115731 if(s_version >= 10)
3984 {
3985
2/4
✓ Branch 0 taken 17109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17109 times.
✗ Branch 3 not taken.
17109 if(!p_getc(&tempMsgString.drawlayer,f))
3986 {
3987 return qe_invalid;
3988 }
3989 17109 }
3990
3991
2/4
✓ Branch 0 taken 115731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115731 times.
✗ Branch 3 not taken.
115731 if(!p_getc(&tempMsgString.sfx,f))
3992 {
3993 return qe_invalid;
3994 }
3995
3996
1/2
✓ Branch 0 taken 115731 times.
✗ Branch 1 not taken.
115731 if(s_version>3)
3997 {
3998
2/4
✓ Branch 0 taken 115731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115731 times.
✗ Branch 3 not taken.
115731 if(!p_igetw(&tempMsgString.listpos,f))
3999 {
4000 return qe_invalid;
4001 }
4002 115731 }
4003 }
4004
4005
1/2
✓ Branch 0 taken 149344 times.
✗ Branch 1 not taken.
149344 if (!should_skip)
4006 {
4007
1/2
✓ Branch 0 taken 149344 times.
✗ Branch 1 not taken.
149344 MsgStrings[i].copyAll(tempMsgString);
4008 149344 }
4009 149344 }
4010 }
4011
4012
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 490 times.
491 if (!should_skip)
4013 490 msg_count=temp_msg_count;
4014
4015 491 return 0;
4016 491 }
4017
4018 491 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
4019 {
4020
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 24 times.
491 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_doors);
4021
4022
3/4
✓ Branch 0 taken 473 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
497 if((Header->zelda_version < 0x192)||
4023
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 467 times.
473 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4024 {
4025 18 return 0;
4026 }
4027
4028 473 word temp_door_combo_set_count=0;
4029 DoorComboSet tempDoorComboSet;
4030 word dummy_word;
4031 int32_t dummy_long;
4032 byte padding;
4033 473 int32_t s_version = 0;
4034
4035
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 472 times.
473 if (!should_skip)
4036 {
4037 472 DoorComboSets = {};
4038 472 DoorComboSetNames = {};
4039 472 }
4040
4041
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 467 times.
473 if(Header->zelda_version > 0x192)
4042 {
4043 //section version info
4044
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if(!p_igetw(&s_version,f))
4045 {
4046 return qe_invalid;
4047 }
4048
4049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if (s_version > V_DOORS)
4050 return qe_version;
4051
4052 467 FFCore.quest_format[vDoors] = s_version;
4053
4054
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if(!p_igetw(&dummy_word,f))
4055 {
4056 return qe_invalid;
4057 }
4058
4059 //section size
4060
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if(!p_igetl(&dummy_long,f))
4061 {
4062 return qe_invalid;
4063 }
4064 467 }
4065
4066 //finally... section data
4067
1/2
✓ Branch 0 taken 473 times.
✗ Branch 1 not taken.
473 if(!p_igetw(&temp_door_combo_set_count,f))
4068 {
4069 return qe_invalid;
4070 }
4071
4072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473 times.
473 if (temp_door_combo_set_count > MAXDOORCOMBOSETS)
4073 {
4074 return qe_invalid;
4075 }
4076
4077
2/2
✓ Branch 0 taken 5669 times.
✓ Branch 1 taken 473 times.
6142 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4078 {
4079 5669 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4080
4081 //name
4082 char name[21];
4083
1/2
✓ Branch 0 taken 5669 times.
✗ Branch 1 not taken.
5669 if(!pfread(&name,sizeof(name),f))
4084 {
4085 return qe_invalid;
4086 }
4087
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5655 times.
5669 if (!should_skip)
4088 5655 DoorComboSetNames[i] = name;
4089
4090
2/2
✓ Branch 0 taken 5629 times.
✓ Branch 1 taken 40 times.
5669 if(Header->zelda_version < 0x193)
4091 {
4092
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&padding,f))
4093 {
4094 return qe_invalid;
4095 }
4096 40 }
4097
4098 //up door
4099
2/2
✓ Branch 0 taken 51021 times.
✓ Branch 1 taken 5669 times.
56690 for(int32_t j=0; j<9; j++)
4100 {
4101
2/2
✓ Branch 0 taken 204084 times.
✓ Branch 1 taken 51021 times.
255105 for(int32_t k=0; k<4; k++)
4102 {
4103
1/2
✓ Branch 0 taken 204084 times.
✗ Branch 1 not taken.
204084 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4104 {
4105 return qe_invalid;
4106 }
4107 204084 }
4108 51021 }
4109
4110
2/2
✓ Branch 0 taken 51021 times.
✓ Branch 1 taken 5669 times.
56690 for(int32_t j=0; j<9; j++)
4111 {
4112
2/2
✓ Branch 0 taken 204084 times.
✓ Branch 1 taken 51021 times.
255105 for(int32_t k=0; k<4; k++)
4113 {
4114
1/2
✓ Branch 0 taken 204084 times.
✗ Branch 1 not taken.
204084 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4115 {
4116 return qe_invalid;
4117 }
4118 204084 }
4119 51021 }
4120
4121 //down door
4122
2/2
✓ Branch 0 taken 51021 times.
✓ Branch 1 taken 5669 times.
56690 for(int32_t j=0; j<9; j++)
4123 {
4124
2/2
✓ Branch 0 taken 204084 times.
✓ Branch 1 taken 51021 times.
255105 for(int32_t k=0; k<4; k++)
4125 {
4126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204084 times.
204084 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4127 {
4128 return qe_invalid;
4129 }
4130 204084 }
4131 51021 }
4132
4133
2/2
✓ Branch 0 taken 51021 times.
✓ Branch 1 taken 5669 times.
56690 for(int32_t j=0; j<9; j++)
4134 {
4135
2/2
✓ Branch 0 taken 204084 times.
✓ Branch 1 taken 51021 times.
255105 for(int32_t k=0; k<4; k++)
4136 {
4137
1/2
✓ Branch 0 taken 204084 times.
✗ Branch 1 not taken.
204084 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4138 {
4139 return qe_invalid;
4140 }
4141 204084 }
4142 51021 }
4143
4144 //left door
4145
2/2
✓ Branch 0 taken 51021 times.
✓ Branch 1 taken 5669 times.
56690 for(int32_t j=0; j<9; j++)
4146 {
4147
2/2
✓ Branch 0 taken 306126 times.
✓ Branch 1 taken 51021 times.
357147 for(int32_t k=0; k<6; k++)
4148 {
4149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306126 times.
306126 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4150 {
4151 return qe_invalid;
4152 }
4153 306126 }
4154 51021 }
4155
4156
2/2
✓ Branch 0 taken 51021 times.
✓ Branch 1 taken 5669 times.
56690 for(int32_t j=0; j<9; j++)
4157 {
4158
2/2
✓ Branch 0 taken 306126 times.
✓ Branch 1 taken 51021 times.
357147 for(int32_t k=0; k<6; k++)
4159 {
4160
1/2
✓ Branch 0 taken 306126 times.
✗ Branch 1 not taken.
306126 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4161 {
4162 return qe_invalid;
4163 }
4164 306126 }
4165 51021 }
4166
4167 //right door
4168
2/2
✓ Branch 0 taken 51021 times.
✓ Branch 1 taken 5669 times.
56690 for(int32_t j=0; j<9; j++)
4169 {
4170
2/2
✓ Branch 0 taken 306126 times.
✓ Branch 1 taken 51021 times.
357147 for(int32_t k=0; k<6; k++)
4171 {
4172
1/2
✓ Branch 0 taken 306126 times.
✗ Branch 1 not taken.
306126 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4173 {
4174 return qe_invalid;
4175 }
4176 306126 }
4177 51021 }
4178
4179
2/2
✓ Branch 0 taken 51021 times.
✓ Branch 1 taken 5669 times.
56690 for(int32_t j=0; j<9; j++)
4180 {
4181
2/2
✓ Branch 0 taken 306126 times.
✓ Branch 1 taken 51021 times.
357147 for(int32_t k=0; k<6; k++)
4182 {
4183
1/2
✓ Branch 0 taken 306126 times.
✗ Branch 1 not taken.
306126 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4184 {
4185 return qe_invalid;
4186 }
4187 306126 }
4188 51021 }
4189
4190 //up bomb rubble
4191
2/2
✓ Branch 0 taken 11338 times.
✓ Branch 1 taken 5669 times.
17007 for(int32_t j=0; j<2; j++)
4192 {
4193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11338 times.
11338 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4194 {
4195 return qe_invalid;
4196 }
4197 11338 }
4198
4199
2/2
✓ Branch 0 taken 11338 times.
✓ Branch 1 taken 5669 times.
17007 for(int32_t j=0; j<2; j++)
4200 {
4201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11338 times.
11338 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4202 {
4203 return qe_invalid;
4204 }
4205 11338 }
4206
4207 //down bomb rubble
4208
2/2
✓ Branch 0 taken 11338 times.
✓ Branch 1 taken 5669 times.
17007 for(int32_t j=0; j<2; j++)
4209 {
4210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11338 times.
11338 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4211 {
4212 return qe_invalid;
4213 }
4214 11338 }
4215
4216
2/2
✓ Branch 0 taken 11338 times.
✓ Branch 1 taken 5669 times.
17007 for(int32_t j=0; j<2; j++)
4217 {
4218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11338 times.
11338 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4219 {
4220 return qe_invalid;
4221 }
4222 11338 }
4223
4224 //left bomb rubble
4225
2/2
✓ Branch 0 taken 17007 times.
✓ Branch 1 taken 5669 times.
22676 for(int32_t j=0; j<3; j++)
4226 {
4227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17007 times.
17007 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4228 {
4229 return qe_invalid;
4230 }
4231 17007 }
4232
4233
2/2
✓ Branch 0 taken 17007 times.
✓ Branch 1 taken 5669 times.
22676 for(int32_t j=0; j<3; j++)
4234 {
4235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17007 times.
17007 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4236 {
4237 return qe_invalid;
4238 }
4239 17007 }
4240
4241
2/2
✓ Branch 0 taken 5629 times.
✓ Branch 1 taken 40 times.
5669 if(Header->zelda_version < 0x193)
4242 {
4243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4244 {
4245 return qe_invalid;
4246 }
4247
4248 40 }
4249
4250 //right bomb rubble
4251
2/2
✓ Branch 0 taken 17007 times.
✓ Branch 1 taken 5669 times.
22676 for(int32_t j=0; j<3; j++)
4252 {
4253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17007 times.
17007 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4254 {
4255 return qe_invalid;
4256 }
4257 17007 }
4258
4259
2/2
✓ Branch 0 taken 17007 times.
✓ Branch 1 taken 5669 times.
22676 for(int32_t j=0; j<3; j++)
4260 {
4261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17007 times.
17007 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4262 {
4263 return qe_invalid;
4264 }
4265 17007 }
4266
4267
2/2
✓ Branch 0 taken 5629 times.
✓ Branch 1 taken 40 times.
5669 if(Header->zelda_version < 0x193)
4268 {
4269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4270 {
4271 return qe_invalid;
4272 }
4273 40 }
4274
4275 //walkthrough stuff
4276
2/2
✓ Branch 0 taken 22676 times.
✓ Branch 1 taken 5669 times.
28345 for(int32_t j=0; j<4; j++)
4277 {
4278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22676 times.
22676 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4279 {
4280 return qe_invalid;
4281 }
4282 22676 }
4283
4284
2/2
✓ Branch 0 taken 22676 times.
✓ Branch 1 taken 5669 times.
28345 for(int32_t j=0; j<4; j++)
4285 {
4286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22676 times.
22676 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4287 {
4288 return qe_invalid;
4289 }
4290 22676 }
4291
4292 //flags
4293
2/2
✓ Branch 0 taken 11338 times.
✓ Branch 1 taken 5669 times.
17007 for(int32_t j=0; j<2; j++)
4294 {
4295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11338 times.
11338 if(!p_getc(&tempDoorComboSet.flags[j],f))
4296 {
4297 return qe_invalid;
4298 }
4299 11338 }
4300
4301
2/2
✓ Branch 0 taken 5629 times.
✓ Branch 1 taken 40 times.
5669 if(Header->zelda_version < 0x193)
4302 {
4303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4304 {
4305 return qe_invalid;
4306 }
4307 40 }
4308
4309
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5655 times.
5669 if (!should_skip)
4310 5655 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4311 5669 }
4312
4313
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 472 times.
473 if (!should_skip)
4314 472 door_combo_set_count=temp_door_combo_set_count;
4315
4316 473 return 0;
4317 491 }
4318
4319 9 int32_t count_dmaps()
4320 {
4321 9 int32_t i=MAXDMAPS-1;
4322 9 bool found=false;
4323
4324
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9 times.
9 while(i>=0 && !found)
4325 {
4326
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
27 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4327
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4328
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4329 18 found=true;
4330
4331
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t j=0; j<8; j++)
4332 {
4333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(DMaps[i].grid[j]!=0)
4334
4335 found=true;
4336 72 }
4337
4338
5/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
18 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4339 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4340 27 found=true;
4341
4342
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
27 if((DMaps[i].minimap_tile[0]!=0)||(DMaps[i].minimap_tile[1]!=0)||
4343
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].largemap_tile[0]!=0)||(DMaps[i].largemap_tile[1]!=0)||
4344
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 (DMaps[i].minimap_cset[0]!=0)||(DMaps[i].minimap_cset[1]!=0)||
4345
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 (DMaps[i].largemap_cset[0]!=0)||(DMaps[i].largemap_cset[1]!=0))
4346 18 found=true;
4347
4348 if(!found)
4349 {
4350 i--;
4351 }
4352 }
4353
4354 9 return i+1;
4355 }
4356
4357
4358 9 int32_t count_shops(miscQdata *Misc)
4359 {
4360 9 int32_t i=NUM_SHOPS-1,j;
4361 9 bool found=false;
4362
4363
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4364 {
4365 2229 j=2;
4366
4367
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4368 {
4369
3/4
✓ Branch 0 taken 6672 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6672 times.
6677 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4370 {
4371 5 found=true;
4372 5 }
4373 else
4374 {
4375 6672 j--;
4376 }
4377 }
4378
4379
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->shop[i].name[0]!=0)
4380 {
4381 found=true;
4382 }
4383
4384
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4385 {
4386 2224 i--;
4387 2224 }
4388 }
4389
4390 9 return i+1;
4391 }
4392
4393 9 int32_t count_infos(miscQdata *Misc)
4394 {
4395 9 int32_t i=255,j;
4396 9 bool found=false;
4397
4398
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2234 times.
✓ Branch 2 taken 2229 times.
✓ Branch 3 taken 9 times.
2238 while(i>=0 && !found)
4399 {
4400 2229 j=2;
4401
4402
4/4
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 6682 times.
✓ Branch 2 taken 6677 times.
✓ Branch 3 taken 2229 times.
8906 while(j>=0 && !found)
4403 {
4404
4/4
✓ Branch 0 taken 6676 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 6672 times.
6677 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4405 {
4406 5 found=true;
4407 5 }
4408 else
4409 {
4410 6672 j--;
4411 }
4412 }
4413
4414
1/2
✓ Branch 0 taken 2229 times.
✗ Branch 1 not taken.
2229 if(Misc->info[i].name[0]!=0)
4415 {
4416 found=true;
4417 }
4418
4419
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2224 times.
2229 if(!found)
4420 {
4421 2224 i--;
4422 2224 }
4423 }
4424
4425 9 return i+1;
4426 }
4427
4428 9 int32_t count_warprings(miscQdata *Misc)
4429 {
4430 9 int32_t i=15,j;
4431 9 bool found=false;
4432
4433
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 9 times.
58 while(i>=0 && !found)
4434 {
4435 49 j=7;
4436
4437
4/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 358 times.
✓ Branch 3 taken 49 times.
407 while(j>=0 && !found)
4438 {
4439
4/4
✓ Branch 0 taken 354 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 349 times.
358 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4440 {
4441 9 found=true;
4442 9 }
4443 else
4444 {
4445 349 j--;
4446 }
4447 }
4448
4449
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 40 times.
49 if(!found)
4450 {
4451 40 i--;
4452 40 }
4453 }
4454
4455 9 return i+1;
4456 }
4457
4458 9 int32_t count_palcycles(miscQdata *Misc)
4459 {
4460 9 int32_t i=255,j;
4461 9 bool found=false;
4462
4463
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2043 times.
✓ Branch 2 taken 2036 times.
✓ Branch 3 taken 9 times.
2045 while(i>=0 && !found)
4464 {
4465 2036 j=2;
4466
4467
4/4
✓ Branch 0 taken 2029 times.
✓ Branch 1 taken 6101 times.
✓ Branch 2 taken 6094 times.
✓ Branch 3 taken 2036 times.
8130 while(j>=0 && !found)
4468 {
4469
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 6087 times.
6094 if(Misc->cycles[i][j].count!=0)
4470 {
4471 7 found=true;
4472 7 }
4473 else
4474 {
4475 6087 j--;
4476 }
4477 }
4478
4479
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2029 times.
2036 if(!found)
4480 {
4481 2029 i--;
4482 2029 }
4483 }
4484
4485 9 return i+1;
4486 }
4487
4488 192168 void clear_screen(mapscr *temp_scr)
4489 {
4490 192168 temp_scr->zero_memory();
4491 192168 }
4492
4493 // NOTE: when modifying this, you need to also update:
4494 // readonedmap, readdmaps, and FFScript::read_dmaps
4495 // (and their associated write functions)
4496 3563 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4497 {
4498
2/2
✓ Branch 0 taken 3539 times.
✓ Branch 1 taken 24 times.
3563 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
4499
4500 3563 word dmapstoread=0;
4501 3563 dmap tempDMap;
4502
4503 int32_t dummy;
4504 3563 word s_version=0;
4505 byte padding;
4506
4507 char legacy_title[22];
4508
4509
2/2
✓ Branch 0 taken 3073 times.
✓ Branch 1 taken 490 times.
3563 if (!should_skip)
4510
2/2
✓ Branch 0 taken 250880 times.
✓ Branch 1 taken 490 times.
251370 for(int32_t i=0; i<max_dmaps; i++)
4511 {
4512
1/2
✓ Branch 0 taken 250880 times.
✗ Branch 1 not taken.
250880 DMaps[start_dmap + i].clear();
4513 250880 sprintf(legacy_title," ");
4514 250880 sprintf(DMaps[start_dmap+i].intro," ");
4515 250880 DMaps[start_dmap+i].type |= dmCAVE;
4516 251370 }
4517
4518
3/4
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 3073 times.
✓ Branch 2 taken 490 times.
✗ Branch 3 not taken.
3563 if (!should_skip && s_version == 21)
4519 Regions = {};
4520
4521 3563 Header->is_z3 = false;
4522
4/4
✓ Branch 0 taken 491 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 467 times.
✓ Branch 3 taken 24 times.
3563 if(!Header || Header->zelda_version > 0x192)
4523 {
4524 //section version info
4525
3/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
3539 if(!p_igetw(&s_version,f))
4526 {
4527 return qe_invalid;
4528 }
4529
4530
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if (s_version > V_DMAPS)
4531 return qe_version;
4532
4533 467 Header->is_z3 = s_version >= 22;
4534 467 FFCore.quest_format[vDMaps] = s_version;
4535
4536
4537
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
467 if(!read_deprecated_section_cversion(f))
4538 {
4539 return qe_invalid;
4540 }
4541
4542 //section size
4543
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
467 if(!p_igetl(&dummy,f))
4544 {
4545 return qe_invalid;
4546 }
4547
4548 //finally... section data
4549
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
467 if(!p_igetw(&dmapstoread,f))
4550 {
4551 return qe_invalid;
4552 }
4553 467 }
4554 else
4555 {
4556
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
4557
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4558 {
4559 18 dmapstoread=32;
4560 18 }
4561
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(s_version <= 4)
4562 {
4563 6 dmapstoread=OLDMAXDMAPS;
4564 6 }
4565 else
4566 {
4567 dmapstoread=MAXDMAPS;
4568 }
4569 }
4570
4571
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 408 times.
491 dmapstoread=zc_min(dmapstoread, max_dmaps);
4572
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 408 times.
491 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4573
4574
2/2
✓ Branch 0 taken 226112 times.
✓ Branch 1 taken 491 times.
226603 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4575 {
4576
1/2
✓ Branch 0 taken 226112 times.
✗ Branch 1 not taken.
226112 tempDMap.clear();
4577 226112 sprintf(legacy_title," ");
4578 226112 sprintf(tempDMap.intro," ");
4579
4580
2/4
✓ Branch 0 taken 226112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226112 times.
✗ Branch 3 not taken.
226112 if(!p_getc(&tempDMap.map,f))
4581 {
4582 return qe_invalid;
4583 }
4584
4585
2/2
✓ Branch 0 taken 17216 times.
✓ Branch 1 taken 208896 times.
226112 if(s_version <= 4)
4586 {
4587 byte tempbyte;
4588
4589
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4590 {
4591 return qe_invalid;
4592 }
4593
4594 17216 tempDMap.level=(word)tempbyte;
4595 17216 }
4596 else
4597 {
4598
2/4
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208896 times.
✗ Branch 3 not taken.
208896 if(!p_igetw(&tempDMap.level,f))
4599 {
4600 return qe_invalid;
4601 }
4602 }
4603
4604
2/4
✓ Branch 0 taken 226112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226112 times.
✗ Branch 3 not taken.
226112 if(!p_getc(&tempDMap.xoff,f))
4605 {
4606 return qe_invalid;
4607 }
4608
4609
2/4
✓ Branch 0 taken 226112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226112 times.
✗ Branch 3 not taken.
226112 if(!p_getc(&tempDMap.compass,f))
4610 {
4611 return qe_invalid;
4612 }
4613
4614
2/2
✓ Branch 0 taken 208896 times.
✓ Branch 1 taken 17216 times.
226112 if(s_version > 8) // February 2009
4615 {
4616
2/4
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208896 times.
✗ Branch 3 not taken.
208896 if(!p_igetw(&tempDMap.color,f))
4617 {
4618 return qe_invalid;
4619 }
4620 208896 }
4621 else
4622 {
4623 byte tempbyte;
4624
4625
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4626 {
4627 return qe_invalid;
4628 }
4629
4630 17216 tempDMap.color = (word)tempbyte;
4631 }
4632
4633
2/4
✓ Branch 0 taken 226112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226112 times.
✗ Branch 3 not taken.
226112 if(!p_getc(&tempDMap.midi,f))
4634 {
4635 return qe_invalid;
4636 }
4637
4638
2/4
✓ Branch 0 taken 226112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226112 times.
✗ Branch 3 not taken.
226112 if(!p_getc(&tempDMap.cont,f))
4639 {
4640 return qe_invalid;
4641 }
4642
4643
2/4
✓ Branch 0 taken 226112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226112 times.
✗ Branch 3 not taken.
226112 if(!p_getc(&tempDMap.type,f))
4644 {
4645 return qe_invalid;
4646 }
4647
4648
4/4
✓ Branch 0 taken 6331 times.
✓ Branch 1 taken 219781 times.
✓ Branch 2 taken 6287 times.
✓ Branch 3 taken 44 times.
232443 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4649
1/2
✓ Branch 0 taken 6331 times.
✗ Branch 1 not taken.
6331 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4650 6287 tempDMap.xoff = 0;
4651
4652
2/2
✓ Branch 0 taken 226112 times.
✓ Branch 1 taken 1808896 times.
2035008 for(int32_t j=0; j<8; j++)
4653 {
4654
2/4
✓ Branch 0 taken 1808896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1808896 times.
✗ Branch 3 not taken.
1808896 if(!p_getc(&tempDMap.grid[j],f))
4655 {
4656 return qe_invalid;
4657 }
4658 1808896 }
4659
4660
5/6
✓ Branch 0 taken 226112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 225536 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 224000 times.
226112 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4661 {
4662
4/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 1975 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 127 times.
2112 if(tempDMap.level>0&&tempDMap.level<10)
4663 {
4664 127 sprintf(legacy_title,"LEVEL-%d ", tempDMap.level);
4665 127 }
4666
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 1536 times.
2112 tempDMap.title.assign(legacy_title);
4667
4668
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 558 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
576 if(i==0 && Header->zelda_version <= 0x190)
4669 {
4670
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.cont = std::max((int)tempDMap.cont - tempDMap.xoff, 0);
4671
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.compass = std::max((int)tempDMap.compass - tempDMap.xoff, 0);
4672 18 }
4673
4674 //forgotten -DD
4675
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 439 times.
576 if(tempDMap.level==0)
4676 {
4677 439 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4678 439 }
4679 576 }
4680 else
4681 {
4682
3/4
✓ Branch 0 taken 225536 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 225536 times.
✗ Branch 3 not taken.
224000 if(!p_getstr(tempDMap.name,sizeof(DMaps[0].name) - 1,f))
4683 {
4684 return qe_invalid;
4685 }
4686
4687
2/2
✓ Branch 0 taken 127744 times.
✓ Branch 1 taken 97792 times.
225536 if(s_version<20)
4688 {
4689
2/4
✓ Branch 0 taken 127744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127744 times.
✗ Branch 3 not taken.
127744 if (!p_getstr(legacy_title, sizeof(legacy_title) - 1, f))
4690 {
4691 return qe_invalid;
4692 }
4693
1/2
✓ Branch 0 taken 127744 times.
✗ Branch 1 not taken.
127744 tempDMap.title.assign(legacy_title);
4694 127744 }
4695 else
4696 {
4697
2/4
✓ Branch 0 taken 97792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97792 times.
✗ Branch 3 not taken.
97792 if (!p_getwstr(&tempDMap.title, f))
4698 {
4699 return qe_invalid;
4700 }
4701 }
4702
4703
2/4
✓ Branch 0 taken 225536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 225536 times.
✗ Branch 3 not taken.
225536 if(!p_getstr(tempDMap.intro,sizeof(DMaps[0].intro)-1,f))
4704 {
4705 return qe_invalid;
4706 }
4707
4708
5/8
✓ Branch 0 taken 225536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 225536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 224000 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1536 times.
225536 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4709 {
4710 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4711 DMaps[i] = tempDMap;
4712
4713 continue;
4714 }
4715
4716
3/4
✓ Branch 0 taken 225536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 224000 times.
225536 if(Header && (Header->zelda_version < 0x193))
4717 {
4718
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4719 {
4720 return qe_invalid;
4721 }
4722 1536 }
4723
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 119040 times.
225536 if ( s_version >= 11 )
4724 {
4725
2/4
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106496 times.
✗ Branch 3 not taken.
106496 if(!p_igetl(&tempDMap.minimap_tile[0],f))
4726 {
4727 return qe_invalid;
4728 }
4729 106496 }
4730 else
4731 {
4732
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.minimap_tile[0],f))
4733 {
4734 return qe_invalid;
4735 }
4736 }
4737
4738
2/4
✓ Branch 0 taken 225536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 225536 times.
✗ Branch 3 not taken.
225536 if(!p_getc(&tempDMap.minimap_cset[0],f))
4739 {
4740 return qe_invalid;
4741 }
4742
4743
3/4
✓ Branch 0 taken 225536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 224000 times.
225536 if(Header && (Header->zelda_version < 0x193))
4744 {
4745
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4746 {
4747 return qe_invalid;
4748 }
4749 1536 }
4750
4751
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 119040 times.
225536 if ( s_version >= 11 )
4752 {
4753
2/4
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106496 times.
✗ Branch 3 not taken.
106496 if(!p_igetl(&tempDMap.minimap_tile[1],f))
4754 {
4755 return qe_invalid;
4756 }
4757 106496 }
4758 else
4759 {
4760
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.minimap_tile[1],f))
4761 {
4762 return qe_invalid;
4763 }
4764 }
4765
2/4
✓ Branch 0 taken 225536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 225536 times.
✗ Branch 3 not taken.
225536 if(!p_getc(&tempDMap.minimap_cset[1],f))
4766 {
4767 return qe_invalid;
4768 }
4769
4770
3/4
✓ Branch 0 taken 225536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 224000 times.
225536 if(Header && (Header->zelda_version < 0x193))
4771 {
4772
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4773 {
4774 return qe_invalid;
4775 }
4776 1536 }
4777
4778
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 119040 times.
225536 if ( s_version >= 11 )
4779 {
4780
2/4
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106496 times.
✗ Branch 3 not taken.
106496 if(!p_igetl(&tempDMap.largemap_tile[0],f))
4781 {
4782 return qe_invalid;
4783 }
4784 106496 }
4785 else
4786 {
4787
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.largemap_tile[0],f))
4788 {
4789 return qe_invalid;
4790 }
4791 }
4792
4793
2/4
✓ Branch 0 taken 225536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 225536 times.
✗ Branch 3 not taken.
225536 if(!p_getc(&tempDMap.largemap_cset[0],f))
4794 {
4795 return qe_invalid;
4796 }
4797
4798
3/4
✓ Branch 0 taken 225536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 224000 times.
225536 if(Header && (Header->zelda_version < 0x193))
4799 {
4800
4801
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4802 {
4803 return qe_invalid;
4804 }
4805 1536 }
4806
4807
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 119040 times.
225536 if ( s_version >= 11 )
4808 {
4809
2/4
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106496 times.
✗ Branch 3 not taken.
106496 if(!p_igetl(&tempDMap.largemap_tile[1],f))
4810 {
4811 return qe_invalid;
4812 }
4813 106496 }
4814 else
4815 {
4816
2/4
✓ Branch 0 taken 119040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119040 times.
✗ Branch 3 not taken.
119040 if(!p_igetw(&tempDMap.largemap_tile[1],f))
4817 {
4818 return qe_invalid;
4819 }
4820 }
4821
2/4
✓ Branch 0 taken 225536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 225536 times.
✗ Branch 3 not taken.
225536 if(!p_getc(&tempDMap.largemap_cset[1],f))
4822 {
4823 return qe_invalid;
4824 }
4825
4826
2/4
✓ Branch 0 taken 225536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 225536 times.
✗ Branch 3 not taken.
225536 if(!p_getstr(tempDMap.tmusic,sizeof(DMaps[0].tmusic)-1,f))
4827 {
4828 return qe_invalid;
4829 }
4830 }
4831
4832
2/2
✓ Branch 0 taken 208896 times.
✓ Branch 1 taken 17216 times.
226112 if(s_version>1)
4833 {
4834
2/4
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208896 times.
✗ Branch 3 not taken.
208896 if(!p_getc(&tempDMap.tmusictrack,f))
4835 {
4836 return qe_invalid;
4837 }
4838
4839
2/4
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208896 times.
✗ Branch 3 not taken.
208896 if(!p_getc(&tempDMap.active_subscreen,f))
4840 {
4841 return qe_invalid;
4842 }
4843
4844
2/4
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208896 times.
✗ Branch 3 not taken.
208896 if(!p_getc(&tempDMap.passive_subscreen,f))
4845 {
4846 return qe_invalid;
4847 }
4848 208896 }
4849
4850
2/2
✓ Branch 0 taken 208896 times.
✓ Branch 1 taken 17216 times.
226112 if(s_version>2)
4851 {
4852 byte di[32];
4853
4854
2/4
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208896 times.
✗ Branch 3 not taken.
208896 if(!pfread(&di, 32, f)) return qe_invalid;
4855
4856
2/2
✓ Branch 0 taken 53477376 times.
✓ Branch 1 taken 208896 times.
53686272 for(int32_t j=0; j<MAXITEMS; j++)
4857 {
4858
2/2
✓ Branch 0 taken 9207 times.
✓ Branch 1 taken 53468169 times.
53477376 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4859 53468169 else tempDMap.disableditems[j]=0;
4860 53477376 }
4861 208896 }
4862
4863
2/2
✓ Branch 0 taken 208896 times.
✓ Branch 1 taken 17216 times.
226112 if(s_version >= 6)
4864 {
4865
2/4
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208896 times.
✗ Branch 3 not taken.
208896 if(!p_igetl(&tempDMap.flags,f))
4866 {
4867 return qe_invalid;
4868 }
4869 208896 }
4870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17216 times.
17216 else if(s_version>3)
4871 {
4872 char temp;
4873
4874 if(!p_getc(&temp,f))
4875 {
4876 return qe_invalid;
4877 }
4878
4879 tempDMap.flags = temp;
4880 }
4881
3/8
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8992 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17216 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4882 {
4883 8992 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4884 8992 }
4885 else
4886 8224 tempDMap.flags=0;
4887
4888
2/2
✓ Branch 0 taken 208896 times.
✓ Branch 1 taken 17216 times.
226112 if(s_version<7)
4889 {
4890
5/6
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8992 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6146 times.
✓ Branch 5 taken 2846 times.
17216 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4891 6146 tempDMap.flags|= dmfVIEWMAP;
4892 17216 }
4893
4894
2/2
✓ Branch 0 taken 208896 times.
✓ Branch 1 taken 17216 times.
226112 if(s_version<8)
4895 {
4896
4/4
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8050 times.
✓ Branch 3 taken 942 times.
17216 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4897 {
4898
1/2
✓ Branch 0 taken 8050 times.
✗ Branch 1 not taken.
8050 tempDMap.type &= ~dmDNGN;
4899 8050 tempDMap.type |= dmCAVE;
4900 8050 }
4901
2/2
✓ Branch 0 taken 6834 times.
✓ Branch 1 taken 2332 times.
9166 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4902 {
4903 2332 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4904 2332 }
4905 17216 }
4906
4907
7/8
✓ Branch 0 taken 226112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2112 times.
✓ Branch 3 taken 224000 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 576 times.
✓ Branch 6 taken 1536 times.
✓ Branch 7 taken 224000 times.
226112 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4908 225536 && (Header->zelda_version < 0x193))
4909 {
4910
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4911 {
4912 return qe_invalid;
4913 }
4914 1536 }
4915
4916
2/2
✓ Branch 0 taken 119616 times.
✓ Branch 1 taken 106496 times.
226112 if(s_version >= 10)
4917 {
4918
2/4
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106496 times.
✗ Branch 3 not taken.
106496 if(!p_getc(&tempDMap.sideview,f))
4919 {
4920 return qe_invalid;
4921 }
4922 106496 }
4923
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 119616 times.
226112 if(s_version < 10) tempDMap.sideview = 0;
4924
4925 //Dmap Scripts
4926
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 119616 times.
226112 if(s_version >= 12)
4927 {
4928
2/4
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106496 times.
✗ Branch 3 not taken.
106496 if(!p_igetw(&tempDMap.script,f))
4929 {
4930 return qe_invalid;
4931 }
4932
2/2
✓ Branch 0 taken 851968 times.
✓ Branch 1 taken 106496 times.
958464 for ( int32_t q = 0; q < 8; q++ )
4933 {
4934
2/4
✓ Branch 0 taken 851968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 851968 times.
✗ Branch 3 not taken.
851968 if(!p_igetl(&tempDMap.initD[q],f))
4935 {
4936 return qe_invalid;
4937 }
4938 851968 }
4939 106496 }
4940
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 119616 times.
226112 if ( s_version < 12 )
4941 {
4942 119616 tempDMap.script = 0;
4943
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for ( int32_t q = 0; q < 8; q++ )
4944 {
4945 956928 tempDMap.initD[q] = 0;
4946 956928 }
4947 119616 }
4948
4949
2/2
✓ Branch 0 taken 119616 times.
✓ Branch 1 taken 106496 times.
226112 if(s_version >= 13)
4950 {
4951
2/2
✓ Branch 0 taken 851968 times.
✓ Branch 1 taken 106496 times.
958464 for ( int32_t q = 0; q < 8; q++ )
4952 {
4953
2/2
✓ Branch 0 taken 55377920 times.
✓ Branch 1 taken 851968 times.
56229888 for ( int32_t w = 0; w < 65; w++ )
4954 {
4955
2/4
✓ Branch 0 taken 55377920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55377920 times.
✗ Branch 3 not taken.
55377920 if(!p_getc(&tempDMap.initD_label[q][w],f))
4956 {
4957 return qe_invalid;
4958 }
4959 55377920 }
4960 851968 }
4961 106496 }
4962
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 119616 times.
226112 if ( s_version < 13 )
4963 {
4964 119616 tempDMap.script = 0;
4965
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for ( int32_t q = 0; q < 8; q++ )
4966 {
4967
2/2
✓ Branch 0 taken 62200320 times.
✓ Branch 1 taken 956928 times.
63157248 for ( int32_t w = 0; w < 65; w++ )
4968 62200320 tempDMap.initD_label[q][w] = 0;
4969 956928 }
4970 119616 }
4971
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 119616 times.
226112 if(s_version >= 14)
4972 {
4973
2/4
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106496 times.
✗ Branch 3 not taken.
106496 if(!p_igetw(&tempDMap.active_sub_script,f))
4974 {
4975 return qe_invalid;
4976 }
4977
2/4
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106496 times.
✗ Branch 3 not taken.
106496 if(!p_igetw(&tempDMap.passive_sub_script,f))
4978 {
4979 return qe_invalid;
4980 }
4981
2/2
✓ Branch 0 taken 851968 times.
✓ Branch 1 taken 106496 times.
958464 for ( int32_t q = 0; q < 8; ++q )
4982 {
4983
2/4
✓ Branch 0 taken 851968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 851968 times.
✗ Branch 3 not taken.
851968 if(!p_igetl(&tempDMap.sub_initD[q],f))
4984 {
4985 return qe_invalid;
4986 }
4987 851968 }
4988
2/2
✓ Branch 0 taken 851968 times.
✓ Branch 1 taken 106496 times.
958464 for(int32_t q = 0; q < 8; ++q)
4989 {
4990
2/2
✓ Branch 0 taken 55377920 times.
✓ Branch 1 taken 851968 times.
56229888 for ( int32_t w = 0; w < 65; ++w )
4991 {
4992
2/4
✓ Branch 0 taken 55377920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55377920 times.
✗ Branch 3 not taken.
55377920 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
4993 {
4994 return qe_invalid;
4995 }
4996 55377920 }
4997 851968 }
4998 106496 }
4999 else
5000 {
5001 119616 tempDMap.active_sub_script = 0;
5002 119616 tempDMap.passive_sub_script = 0;
5003
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for(int32_t q = 0; q < 8; ++q)
5004 {
5005 956928 tempDMap.sub_initD[q] = 0;
5006
2/2
✓ Branch 0 taken 62200320 times.
✓ Branch 1 taken 956928 times.
63157248 for(int32_t w = 0; w < 65; ++w)
5007 62200320 tempDMap.sub_initD_label[q][w] = 0;
5008 956928 }
5009 }
5010
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 119616 times.
226112 if(s_version >= 15)
5011 {
5012
2/4
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106496 times.
✗ Branch 3 not taken.
106496 if(!p_igetw(&tempDMap.onmap_script,f))
5013 {
5014 return qe_invalid;
5015 }
5016
2/2
✓ Branch 0 taken 851968 times.
✓ Branch 1 taken 106496 times.
958464 for ( int32_t q = 0; q < 8; ++q )
5017 {
5018
2/4
✓ Branch 0 taken 851968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 851968 times.
✗ Branch 3 not taken.
851968 if(!p_igetl(&tempDMap.onmap_initD[q],f))
5019 {
5020 return qe_invalid;
5021 }
5022 851968 }
5023
2/2
✓ Branch 0 taken 851968 times.
✓ Branch 1 taken 106496 times.
958464 for(int32_t q = 0; q < 8; ++q)
5024 {
5025
2/2
✓ Branch 0 taken 55377920 times.
✓ Branch 1 taken 851968 times.
56229888 for ( int32_t w = 0; w < 65; ++w )
5026 {
5027
2/4
✓ Branch 0 taken 55377920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55377920 times.
✗ Branch 3 not taken.
55377920 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
5028 {
5029 return qe_invalid;
5030 }
5031 55377920 }
5032 851968 }
5033 106496 }
5034 else
5035 {
5036 119616 tempDMap.onmap_script = 0;
5037
2/2
✓ Branch 0 taken 956928 times.
✓ Branch 1 taken 119616 times.
1076544 for(int32_t q = 0; q < 8; ++q)
5038 {
5039 956928 tempDMap.onmap_initD[q] = 0;
5040
2/2
✓ Branch 0 taken 62200320 times.
✓ Branch 1 taken 956928 times.
63157248 for(int32_t w = 0; w < 65; ++w)
5041 {
5042 62200320 tempDMap.onmap_initD_label[q][w] = 0;
5043 62200320 }
5044 956928 }
5045 }
5046
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 119616 times.
226112 if(s_version >= 16)
5047 {
5048
2/4
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106496 times.
✗ Branch 3 not taken.
106496 if(!p_igetw(&tempDMap.mirrorDMap,f))
5049 {
5050 return qe_invalid;
5051 }
5052 106496 }
5053 else
5054 {
5055 119616 tempDMap.mirrorDMap = -1;
5056 }
5057
5058 // Enhanced music loop points
5059
2/2
✓ Branch 0 taken 97792 times.
✓ Branch 1 taken 128320 times.
226112 if (s_version >= 18)
5060 {
5061
2/4
✓ Branch 0 taken 97792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97792 times.
✗ Branch 3 not taken.
97792 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
5062 {
5063 return qe_invalid;
5064 }
5065
2/4
✓ Branch 0 taken 97792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97792 times.
✗ Branch 3 not taken.
97792 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
5066 {
5067 return qe_invalid;
5068 }
5069
2/4
✓ Branch 0 taken 97792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97792 times.
✗ Branch 3 not taken.
97792 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
5070 {
5071 return qe_invalid;
5072 }
5073
2/4
✓ Branch 0 taken 97792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97792 times.
✗ Branch 3 not taken.
97792 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
5074 {
5075 return qe_invalid;
5076 }
5077 97792 }
5078 else
5079 {
5080 128320 tempDMap.tmusic_loop_start = 0;
5081 128320 tempDMap.tmusic_loop_end = 0;
5082 128320 tempDMap.tmusic_xfade_in = 0;
5083 128320 tempDMap.tmusic_xfade_out = 0;
5084 }
5085
5086
2/2
✓ Branch 0 taken 97792 times.
✓ Branch 1 taken 128320 times.
226112 if(s_version >= 19)
5087
2/4
✓ Branch 0 taken 97792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97792 times.
✗ Branch 3 not taken.
97792 if(!p_getc(&tempDMap.overlay_subscreen, f))
5088 return qe_invalid;
5089
5090
2/2
✓ Branch 0 taken 97792 times.
✓ Branch 1 taken 128320 times.
226112 if (s_version >= 20)
5091 {
5092
2/4
✓ Branch 0 taken 97792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97792 times.
✗ Branch 3 not taken.
97792 if (!p_igetl(&tempDMap.intro_string_id, f))
5093 return qe_invalid;
5094 97792 }
5095 else
5096 128320 tempDMap.intro_string_id = 0;
5097
5098
2/2
✓ Branch 0 taken 211776 times.
✓ Branch 1 taken 14336 times.
226112 if(s_version == 21)
5099 {
5100 static regions_data tmp_rd;
5101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14336 times.
14336 regions_data& rd = should_skip ? tmp_rd : Regions[tempDMap.map];
5102
2/2
✓ Branch 0 taken 114688 times.
✓ Branch 1 taken 14336 times.
129024 for(int32_t j=0; j<8; j++)
5103 {
5104
2/2
✓ Branch 0 taken 917504 times.
✓ Branch 1 taken 114688 times.
1032192 for(int32_t k=0; k<8; k++)
5105 {
5106
2/4
✓ Branch 0 taken 917504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 917504 times.
✗ Branch 3 not taken.
917504 if(!p_getc(&rd.region_ids[j][k],f))
5107 {
5108 return qe_invalid;
5109 }
5110 917504 }
5111 114688 }
5112 14336 }
5113
5114
3/4
✓ Branch 0 taken 74752 times.
✓ Branch 1 taken 151360 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 74752 times.
226112 if (s_version > 22 && (tempDMap.flags & dmfCUSTOM_GRAVITY))
5115 {
5116 if (!p_igetzf(&tempDMap.dmap_gravity, f))
5117 return qe_invalid;
5118 if (!p_igetzf(&tempDMap.dmap_terminal_v, f))
5119 return qe_invalid;
5120 }
5121
5122
2/2
✓ Branch 0 taken 225856 times.
✓ Branch 1 taken 256 times.
226112 if (!should_skip)
5123 {
5124
1/2
✓ Branch 0 taken 225856 times.
✗ Branch 1 not taken.
225856 if(loading_tileset_flags & TILESET_CLEARMAPS)
5125 tempDMap.map = 0;
5126
1/2
✓ Branch 0 taken 225856 times.
✗ Branch 1 not taken.
225856 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
5127 {
5128 tempDMap.script = 0;
5129 for(int q = 0; q < 8; ++q)
5130 tempDMap.initD[q] = 0;
5131 }
5132
1/2
✓ Branch 0 taken 225856 times.
✗ Branch 1 not taken.
225856 DMaps[i] = tempDMap;
5133 225856 }
5134 226112 }
5135
5136 491 return 0;
5137 6635 }
5138
5139 408 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5140 {
5141 //these are here to bypass compiler warnings about unused arguments
5142 408 Header=Header;
5143
5144 miscQdata temp_misc;
5145 408 word s_version=0;
5146 408 int32_t tempsize=0;
5147 word dummyw;
5148
5149 408 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5150
5151 //section version info
5152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(!p_igetw(&s_version,f))
5153 {
5154 return qe_invalid;
5155 }
5156
5157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if (s_version > V_COLORS)
5158 return qe_version;
5159
5160 408 FFCore.quest_format[vColours] = s_version;
5161
5162 408 al_trace("Misc Colours section version: %d\n", s_version);
5163
5164
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!read_deprecated_section_cversion(f))
5165 {
5166 return qe_invalid;
5167 }
5168
5169
5170 //section size
5171
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_igetl(&tempsize,f))
5172 {
5173 return qe_invalid;
5174 }
5175
5176 //finally... section data
5177 408 readsize=0;
5178
5179
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.text,f))
5180 {
5181 return qe_invalid;
5182 }
5183
5184
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.caption,f))
5185 {
5186 return qe_invalid;
5187 }
5188
5189
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.overw_bg,f))
5190 {
5191 return qe_invalid;
5192 }
5193
5194
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5195 {
5196 return qe_invalid;
5197 }
5198
5199
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5200 {
5201 return qe_invalid;
5202 }
5203
5204
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.cave_fg,f))
5205 {
5206 return qe_invalid;
5207 }
5208
5209
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.bs_dk,f))
5210 {
5211 return qe_invalid;
5212 }
5213
5214
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.bs_goal,f))
5215 {
5216 return qe_invalid;
5217 }
5218
5219
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.compass_lt,f))
5220 {
5221 return qe_invalid;
5222 }
5223
5224
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.compass_dk,f))
5225 {
5226 return qe_invalid;
5227 }
5228
5229
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5230 {
5231 return qe_invalid;
5232 }
5233
5234
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.triframe_color,f))
5235 {
5236 return qe_invalid;
5237 }
5238
5239
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.hero_dot,f))
5240 {
5241 return qe_invalid;
5242 }
5243
5244
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5245 {
5246 return qe_invalid;
5247 }
5248
5249
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5250 {
5251 return qe_invalid;
5252 }
5253
5254
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5255 {
5256 return qe_invalid;
5257 }
5258
5259
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5260 {
5261 return qe_invalid;
5262 }
5263
5264
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5265 {
5266 return qe_invalid;
5267 }
5268
5269
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5270 {
5271 return qe_invalid;
5272 }
5273
5274
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5275 {
5276 return qe_invalid;
5277 }
5278
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 200 times.
408 if(s_version < 4)
5279 {
5280
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5281 return qe_invalid;
5282 200 temp_misc.colors.triforce_tile = dummyw;
5283
5284
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5285 return qe_invalid;
5286 200 temp_misc.colors.triframe_tile = dummyw;
5287
5288
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5289 return qe_invalid;
5290 200 temp_misc.colors.overworld_map_tile = dummyw;
5291
5292
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5293 return qe_invalid;
5294 200 temp_misc.colors.dungeon_map_tile = dummyw;
5295
5296
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5297 return qe_invalid;
5298 200 temp_misc.colors.blueframe_tile = dummyw;
5299
5300
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&dummyw,f))
5301 return qe_invalid;
5302 200 temp_misc.colors.HCpieces_tile = dummyw;
5303 200 }
5304
5305
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5306 {
5307 return qe_invalid;
5308 }
5309
5310
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5311 {
5312 return qe_invalid;
5313 }
5314
5315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(s_version < 2)
5316 {
5317 temp_misc.colors.msgtext = 0x01;
5318 }
5319 else
5320 {
5321
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_getc(&temp_misc.colors.msgtext, f))
5322 {
5323 return qe_invalid;
5324 }
5325 }
5326
5327
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 208 times.
408 if ( s_version >= 3 ) //expanded tile pages to 825
5328 {
5329
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5330 {
5331 return qe_invalid;
5332 }
5333
5334
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5335 {
5336 return qe_invalid;
5337 }
5338
5339
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5340 {
5341 return qe_invalid;
5342 }
5343
5344
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5345 {
5346 return qe_invalid;
5347 }
5348
5349
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5350 {
5351 return qe_invalid;
5352 }
5353
5354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
208 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5355 {
5356 return qe_invalid;
5357 }
5358 208 }
5359
5360 408 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5361
5362 408 return 0;
5363 408 }
5364
5365 408 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5366 {
5367 miscQdata temp_misc;
5368 408 word s_version=0;
5369 byte icons;
5370 408 int32_t tempsize=0;
5371
5372 408 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5373
5374 //section version info
5375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(!p_igetw(&s_version,f))
5376 {
5377 return qe_invalid;
5378 }
5379
5380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if (s_version > V_ICONS)
5381 return qe_version;
5382
5383 408 FFCore.quest_format[vIcons] = s_version;
5384
5385
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!read_deprecated_section_cversion(f))
5386 {
5387 return qe_invalid;
5388 }
5389
5390
5391 //section size
5392
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_igetl(&tempsize,f))
5393 {
5394 return qe_invalid;
5395 }
5396
5397 //finally... section data
5398 408 readsize=0;
5399
5400 408 icons=4;
5401
5402
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 200 times.
408 if ( s_version >= 10 )
5403 {
5404
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t i=0; i<icons; i++)
5405 {
5406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_igetl(&temp_misc.icons[i],f))
5407 {
5408 return qe_invalid;
5409 }
5410 832 }
5411 208 }
5412 else
5413 {
5414
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<icons; i++)
5415 {
5416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 if(!p_igetw(&temp_misc.icons[i],f))
5417 {
5418 return qe_invalid;
5419 }
5420 800 }
5421 }
5422
5423 408 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5424
5425 408 return 0;
5426 408 }
5427
5428 820 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5429 {
5430
2/2
✓ Branch 0 taken 796 times.
✓ Branch 1 taken 24 times.
820 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_misc);
5431
5432 820 word maxinfos=256;
5433 820 word maxshops=256;
5434 820 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5435 820 word ponds=16, pondsize=72, expansionsize=98*2;
5436 byte tempbyte, padding;
5437 miscQdata temp_misc;
5438 820 word s_version=0;
5439 word swaptmp;
5440 820 int32_t tempsize=0;
5441
5442 820 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5443
5444
2/2
✓ Branch 0 taken 209920 times.
✓ Branch 1 taken 820 times.
210740 for(int32_t i=0; i<maxshops; ++i)
5445 {
5446 209920 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5447 209920 }
5448
5449
2/2
✓ Branch 0 taken 209920 times.
✓ Branch 1 taken 820 times.
210740 for(int32_t i=0; i<maxinfos; ++i)
5450 {
5451 209920 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5452 209920 }
5453
5454 820 memset(&temp_misc.warp, 0, sizeof(temp_misc.warp));
5455
5456
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 796 times.
820 if(Header->zelda_version > 0x192)
5457 {
5458 //section version info
5459
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_igetw(&s_version,f))
5460 {
5461 return qe_invalid;
5462 }
5463
5464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 796 times.
796 if (s_version > V_MISC)
5465 return qe_version;
5466
5467 796 FFCore.quest_format[vMisc] = s_version;
5468
5469
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!read_deprecated_section_cversion(f))
5470 {
5471 return qe_invalid;
5472 }
5473
5474
5475 //section size
5476
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_igetl(&tempsize,f))
5477 {
5478 return qe_invalid;
5479 }
5480 796 }
5481
5482 //finally... section data
5483 820 readsize=0;
5484
5485 //shops
5486
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 796 times.
820 if(Header->zelda_version > 0x192)
5487 {
5488
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_igetw(&shops,f))
5489 {
5490 return qe_invalid;
5491 }
5492 796 }
5493
5494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 820 times.
820 if (shops > NUM_SHOPS)
5495 {
5496 return qe_invalid;
5497 }
5498
5499
2/2
✓ Branch 0 taken 11198 times.
✓ Branch 1 taken 820 times.
12018 for(int32_t i=0; i<shops; i++)
5500 {
5501
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 9998 times.
11198 if(s_version > 6)
5502 {
5503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9998 times.
9998 if(!p_getstr(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name)-1,f))
5504 {
5505 return qe_invalid;
5506 }
5507 9998 }
5508
5509
2/2
✓ Branch 0 taken 33594 times.
✓ Branch 1 taken 11198 times.
44792 for(int32_t j=0; j<3; j++)
5510 {
5511
1/2
✓ Branch 0 taken 33594 times.
✗ Branch 1 not taken.
33594 if(!p_getc(&temp_misc.shop[i].item[j],f))
5512 {
5513 return qe_invalid;
5514 }
5515
5516
2/2
✓ Branch 0 taken 29994 times.
✓ Branch 1 taken 3600 times.
33594 if(s_version < 4)
5517 {
5518 3600 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5519 3600 }
5520 33594 }
5521
5522
2/2
✓ Branch 0 taken 10814 times.
✓ Branch 1 taken 384 times.
11198 if(Header->zelda_version < 0x193)
5523 {
5524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_getc(&tempbyte,f))
5525 {
5526 return qe_invalid;
5527 }
5528 384 }
5529
5530
2/2
✓ Branch 0 taken 33594 times.
✓ Branch 1 taken 11198 times.
44792 for(int32_t j=0; j<3; j++)
5531 {
5532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33594 times.
33594 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5533 {
5534 return qe_invalid;
5535 }
5536 33594 }
5537
5538
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 9998 times.
11198 if(s_version > 3)
5539 {
5540
2/2
✓ Branch 0 taken 29994 times.
✓ Branch 1 taken 9998 times.
39992 for(int32_t j=0; j<3; j++)
5541 {
5542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29994 times.
29994 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5543 return qe_invalid;
5544 29994 }
5545 9998 }
5546
5547 /*
5548 if(s_version < 8)
5549 {
5550 for(int32_t j=0; j<3; j++)
5551 {
5552 (&temp_misc.shop[i].str[j])=0; //initialise.
5553 }
5554 }
5555 */
5556 11198 }
5557
5558 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5559
2/2
✓ Branch 0 taken 209920 times.
✓ Branch 1 taken 820 times.
210740 for(int32_t i=0; i<maxshops; ++i)
5560 {
5561
2/2
✓ Branch 0 taken 419840 times.
✓ Branch 1 taken 209920 times.
629760 for(int32_t j=0; j<3-1; j++)
5562 {
5563
2/2
✓ Branch 0 taken 629760 times.
✓ Branch 1 taken 419840 times.
1049600 for(int32_t k=0; k<2-j; k++)
5564 {
5565
2/2
✓ Branch 0 taken 605577 times.
✓ Branch 1 taken 24183 times.
629760 if(temp_misc.shop[i].hasitem[k]==0)
5566 {
5567 605577 swaptmp = temp_misc.shop[i].item[k];
5568 605577 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5569 605577 temp_misc.shop[i].item[k+1] = swaptmp;
5570 605577 swaptmp = temp_misc.shop[i].price[k];
5571 605577 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5572 605577 temp_misc.shop[i].price[k+1] = swaptmp;
5573 605577 swaptmp = temp_misc.shop[i].hasitem[k];
5574 605577 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5575 605577 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5576 605577 }
5577 629760 }
5578 419840 }
5579 209920 }
5580
5581 //infos
5582
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 796 times.
820 if(Header->zelda_version > 0x192)
5583 {
5584
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_igetw(&infos,f))
5585 {
5586 return qe_invalid;
5587 }
5588 796 }
5589
5590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 820 times.
820 if (infos > NUM_INFOS)
5591 {
5592 return qe_invalid;
5593 }
5594
5595
5596
2/2
✓ Branch 0 taken 10504 times.
✓ Branch 1 taken 820 times.
11324 for(int32_t i=0; i<infos; i++)
5597 {
5598
2/2
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 9743 times.
10504 if(s_version > 6)
5599 {
5600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9743 times.
9743 if(!p_getstr(temp_misc.info[i].name,sizeof(temp_misc.info[i].name)-1,f))
5601 {
5602 return qe_invalid;
5603 }
5604 9743 }
5605
5606
2/2
✓ Branch 0 taken 31512 times.
✓ Branch 1 taken 10504 times.
42016 for(int32_t j=0; j<3; j++)
5607 {
5608
3/4
✓ Branch 0 taken 30648 times.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288 times.
31800 if((Header->zelda_version < 0x192)||
5609
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 30360 times.
30648 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5610 {
5611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
864 if(!p_getc(&tempbyte,f))
5612 {
5613 return qe_invalid;
5614 }
5615
5616 864 temp_misc.info[i].str[j]=tempbyte;
5617 864 }
5618 else
5619 {
5620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30648 times.
30648 if(!p_igetw(&temp_misc.info[i].str[j],f))
5621 {
5622 return qe_invalid;
5623 }
5624 }
5625 31512 }
5626
5627
2/2
✓ Branch 0 taken 10120 times.
✓ Branch 1 taken 384 times.
10504 if(Header->zelda_version < 0x193)
5628 {
5629
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&tempbyte,f))
5630 {
5631 return qe_invalid;
5632 }
5633 384 }
5634
5635
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 10408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
10504 if((Header->zelda_version == 0x192)&&(Header->build>145))
5636 {
5637
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&padding,f))
5638 {
5639 return qe_invalid;
5640 }
5641 96 }
5642
5643
2/2
✓ Branch 0 taken 31512 times.
✓ Branch 1 taken 10504 times.
42016 for(int32_t j=0; j<3; j++)
5644 {
5645
1/2
✓ Branch 0 taken 31512 times.
✗ Branch 1 not taken.
31512 if(!p_igetw(&temp_misc.info[i].price[j],f))
5646 {
5647 return qe_invalid;
5648 }
5649 31512 }
5650 10504 }
5651
5652 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5653
2/2
✓ Branch 0 taken 209920 times.
✓ Branch 1 taken 820 times.
210740 for(int32_t i=0; i<maxinfos; ++i)
5654 {
5655
2/2
✓ Branch 0 taken 419840 times.
✓ Branch 1 taken 209920 times.
629760 for(int32_t j=0; j<3-1; j++)
5656 {
5657
2/2
✓ Branch 0 taken 629760 times.
✓ Branch 1 taken 419840 times.
1049600 for(int32_t k=0; k<2-j; k++)
5658 {
5659
2/2
✓ Branch 0 taken 11896 times.
✓ Branch 1 taken 617864 times.
629760 if(temp_misc.info[i].str[k]==0)
5660 {
5661 617864 swaptmp = temp_misc.info[i].str[k];
5662 617864 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5663 617864 temp_misc.info[i].str[k+1] = swaptmp;
5664 617864 swaptmp = temp_misc.info[i].price[k];
5665 617864 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5666 617864 temp_misc.info[i].price[k+1] = swaptmp;
5667 617864 }
5668 629760 }
5669 419840 }
5670 209920 }
5671
5672
5673 //warp rings
5674
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 737 times.
820 if(s_version > 5)
5675 737 warprings++;
5676
5677
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 796 times.
820 if(Header->zelda_version > 0x192)
5678 {
5679
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_igetw(&warprings,f))
5680 {
5681 return qe_invalid;
5682 }
5683
5684
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 456 times.
796 if (warprings > NUM_WARP_RINGS)
5685 {
5686 // return qe_invalid;
5687 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5688 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5689 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5690 456 }
5691 796 }
5692
5693
2/2
✓ Branch 0 taken 8620 times.
✓ Branch 1 taken 820 times.
9440 for(int32_t i=0; i<warprings; i++)
5694 {
5695 // See above comment on the `warprings` range check.
5696 8620 bool keepdata = i < NUM_WARP_RINGS;
5697
5698
2/2
✓ Branch 0 taken 76460 times.
✓ Branch 1 taken 8620 times.
85080 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5699 {
5700
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 67500 times.
76460 if(s_version <= 3)
5701 {
5702
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_getc(&tempbyte,f))
5703 {
5704 return qe_invalid;
5705 }
5706
5707
2/2
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 5768 times.
8960 if (keepdata)
5708 5768 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5709 8960 }
5710 else
5711 {
5712 word tempword;
5713
1/2
✓ Branch 0 taken 67500 times.
✗ Branch 1 not taken.
67500 if(!p_igetw(&tempword,f))
5714 {
5715 return qe_invalid;
5716 }
5717
5718
2/2
✓ Branch 0 taken 8109 times.
✓ Branch 1 taken 59391 times.
67500 if (keepdata)
5719 59391 temp_misc.warp[i].dmap[j] = tempword;
5720 }
5721 76460 }
5722
5723
2/2
✓ Branch 0 taken 76460 times.
✓ Branch 1 taken 8620 times.
85080 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5724 {
5725
1/2
✓ Branch 0 taken 76460 times.
✗ Branch 1 not taken.
76460 if(!p_getc(&tempbyte,f))
5726 {
5727 return qe_invalid;
5728 }
5729
2/2
✓ Branch 0 taken 11301 times.
✓ Branch 1 taken 65159 times.
76460 if (keepdata)
5730 65159 temp_misc.warp[i].scr[j] = tempbyte;
5731 76460 }
5732
5733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8620 times.
8620 if(!p_getc(&tempbyte,f))
5734 {
5735 return qe_invalid;
5736 }
5737
2/2
✓ Branch 0 taken 1300 times.
✓ Branch 1 taken 7320 times.
8620 if (keepdata)
5738 7320 temp_misc.warp[i].size = tempbyte;
5739
5740
2/2
✓ Branch 0 taken 8428 times.
✓ Branch 1 taken 192 times.
8620 if(Header->zelda_version < 0x193)
5741 {
5742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5743 {
5744 return qe_invalid;
5745 }
5746 192 }
5747 8620 }
5748
5749 //palette cycles
5750
2/2
✓ Branch 0 taken 796 times.
✓ Branch 1 taken 24 times.
820 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5751 {
5752
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t i=0; i<256; i++)
5753 {
5754
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 6144 times.
24576 for(int32_t j=0; j<3; j++)
5755 {
5756 18432 temp_misc.cycles[i][j].first=0;
5757 18432 temp_misc.cycles[i][j].count=0;
5758 18432 temp_misc.cycles[i][j].speed=0;
5759 18432 }
5760 6144 }
5761
5762
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
5763
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5764 {
5765 18 palcycles=16;
5766 18 }
5767
5768
2/2
✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 24 times.
1848 for(int32_t i=0; i<palcycles; i++)
5769 {
5770
2/2
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 1824 times.
7296 for(int32_t j=0; j<3; j++)
5771 {
5772
1/2
✓ Branch 0 taken 5472 times.
✗ Branch 1 not taken.
5472 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5773 {
5774 return qe_invalid;
5775 }
5776
5777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5778 {
5779 return qe_invalid;
5780 }
5781
5782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5783 {
5784 return qe_invalid;
5785 }
5786 5472 }
5787 1824 }
5788 24 }
5789
5790 //Wind warps are now just another warp ring.
5791
2/2
✓ Branch 0 taken 737 times.
✓ Branch 1 taken 83 times.
820 if(s_version <= 5)
5792 {
5793
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 59 times.
83 if(Header->zelda_version > 0x192)
5794 {
5795
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&windwarps,f))
5796 {
5797 return qe_invalid;
5798 }
5799 59 }
5800
5801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if (windwarps > NUM_WARP_RINGS)
5802 {
5803 return qe_invalid;
5804 }
5805
5806
2/2
✓ Branch 0 taken 665 times.
✓ Branch 1 taken 83 times.
748 for(int32_t i=0; i<windwarps; i++)
5807 {
5808
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version <= 3)
5809 {
5810
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&tempbyte,f))
5811 {
5812 return qe_invalid;
5813 }
5814
5815 665 temp_misc.warp[8].dmap[i]=tempbyte;
5816 665 }
5817 else
5818 {
5819 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5820 {
5821 return qe_invalid;
5822 }
5823 }
5824
5825
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5826 {
5827 return qe_invalid;
5828 }
5829
5830 665 temp_misc.warp[8].size = 9;
5831
5832
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version == 5)
5833 {
5834 if(!p_getc(&tempbyte,f))
5835 {
5836 return qe_invalid;
5837 }
5838 }
5839 665 }
5840 83 }
5841
5842
5843 //triforce pieces
5844
2/2
✓ Branch 0 taken 6560 times.
✓ Branch 1 taken 820 times.
7380 for(int32_t i=0; i<triforces; i++)
5845 {
5846
1/2
✓ Branch 0 taken 6560 times.
✗ Branch 1 not taken.
6560 if(!p_getc(&temp_misc.triforce[i],f))
5847 {
5848 return qe_invalid;
5849 }
5850 6560 }
5851
5852 //misc color data
5853
2/2
✓ Branch 0 taken 737 times.
✓ Branch 1 taken 83 times.
820 if(s_version<3)
5854 {
5855
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.text,f))
5856 {
5857 return qe_invalid;
5858 }
5859
5860
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.caption,f))
5861 {
5862 return qe_invalid;
5863 }
5864
5865
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overw_bg,f))
5866 {
5867 return qe_invalid;
5868 }
5869
5870
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5871 {
5872 return qe_invalid;
5873 }
5874
5875
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5876 {
5877 return qe_invalid;
5878 }
5879
5880
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.cave_fg,f))
5881 {
5882 return qe_invalid;
5883 }
5884
5885
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_dk,f))
5886 {
5887 return qe_invalid;
5888 }
5889
5890
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_goal,f))
5891 {
5892 return qe_invalid;
5893 }
5894
5895
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_lt,f))
5896 {
5897 return qe_invalid;
5898 }
5899
5900
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_dk,f))
5901 {
5902 return qe_invalid;
5903 }
5904
5905
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5906 {
5907 return qe_invalid;
5908 }
5909
5910
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_color,f))
5911 {
5912 return qe_invalid;
5913 }
5914
5915
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.hero_dot,f))
5916 {
5917 return qe_invalid;
5918 }
5919
5920
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5921 {
5922 return qe_invalid;
5923 }
5924
5925
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5926 {
5927 return qe_invalid;
5928 }
5929
5930
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5931 {
5932 return qe_invalid;
5933 }
5934
5935
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5936 {
5937 return qe_invalid;
5938 }
5939
5940
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5941 {
5942 return qe_invalid;
5943 }
5944
5945
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5946 {
5947 return qe_invalid;
5948 }
5949
5950
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5951 {
5952 return qe_invalid;
5953 }
5954
5955
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
5956 {
5957 return qe_invalid;
5958 }
5959
5960
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
5961 {
5962 return qe_invalid;
5963 }
5964
5965
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
5966 {
5967 return qe_invalid;
5968 }
5969
5970
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
5971 {
5972 return qe_invalid;
5973 }
5974
5975
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
5976 {
5977 return qe_invalid;
5978 }
5979
5980
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
5981 {
5982 return qe_invalid;
5983 }
5984
5985
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5986 {
5987 return qe_invalid;
5988 }
5989
5990 83 temp_misc.colors.msgtext = 0x01;
5991
5992
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 24 times.
83 if(Header->zelda_version < 0x193)
5993 {
5994
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 24 times.
192 for(int32_t i=0; i<7; i++)
5995 {
5996
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(!p_getc(&tempbyte,f))
5997 {
5998 return qe_invalid;
5999 }
6000 168 }
6001 24 }
6002
6003
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
83 if((Header->zelda_version == 0x192)&&(Header->build>145))
6004 {
6005
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<256; i++)
6006 {
6007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_getc(&tempbyte,f))
6008 {
6009 return qe_invalid;
6010 }
6011 1536 }
6012 6 }
6013
6014
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(s_version>1)
6015 {
6016 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
6017 {
6018 return qe_invalid;
6019 }
6020 }
6021
6022 //save game icons
6023
3/4
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
89 if((Header->zelda_version < 0x192)||
6024
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 59 times.
65 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6025 {
6026 18 icons=3;
6027 18 }
6028
6029
2/2
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 83 times.
397 for(int32_t i=0; i<icons; i++)
6030 {
6031
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if(!p_igetw(&temp_misc.icons[i],f))
6032 {
6033 return qe_invalid;
6034 }
6035 314 }
6036 83 }
6037
6038
3/4
✓ Branch 0 taken 802 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
826 if((Header->zelda_version < 0x192)||
6039
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 796 times.
802 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6040 {
6041 18 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6042
6043 18 return 0;
6044 }
6045
6046 //pond information
6047
2/2
✓ Branch 0 taken 796 times.
✓ Branch 1 taken 6 times.
802 if(Header->zelda_version < 0x193)
6048 {
6049
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<146))
6050 {
6051 pondsize=25;
6052 }
6053
6054
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 6 times.
102 for(int32_t i=0; i<ponds; i++)
6055 {
6056
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 96 times.
7008 for(int32_t j=0; j<pondsize; j++)
6057 {
6058
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if(!p_getc(&tempbyte,f))
6059 {
6060 return qe_invalid;
6061
6062 }
6063 6912 }
6064 96 }
6065 6 }
6066
6067 //end string
6068
2/4
✓ Branch 0 taken 802 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
808 if((Header->zelda_version < 0x192)||
6069
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 796 times.
802 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6070 {
6071 if(!p_getc(&tempbyte,f))
6072 {
6073 return qe_invalid;
6074 }
6075
6076 temp_misc.endstring=tempbyte;
6077
6078 if(!p_getc(&tempbyte,f))
6079 {
6080 return qe_invalid;
6081 }
6082 }
6083 else
6084 {
6085
1/2
✓ Branch 0 taken 802 times.
✗ Branch 1 not taken.
802 if(!p_igetw(&temp_misc.endstring,f))
6086 {
6087 return qe_invalid;
6088 }
6089 }
6090
6091 //expansion
6092
2/2
✓ Branch 0 taken 796 times.
✓ Branch 1 taken 6 times.
802 if(Header->zelda_version < 0x193)
6093 {
6094
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<73))
6095 {
6096 expansionsize=99*2;
6097 }
6098
6099
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 6 times.
1182 for(int32_t i=0; i<expansionsize; i++)
6100 {
6101
1/2
✓ Branch 0 taken 1176 times.
✗ Branch 1 not taken.
1176 if(!p_getc(&tempbyte,f))
6102 {
6103 return qe_invalid;
6104 }
6105 1176 }
6106 6 }
6107 //shops v8
6108
6109
6110
2/2
✓ Branch 0 taken 594 times.
✓ Branch 1 taken 208 times.
802 if(s_version >= 8)
6111 {
6112
2/2
✓ Branch 0 taken 2416 times.
✓ Branch 1 taken 208 times.
2624 for(int32_t i=0; i<shops; i++)
6113 {
6114
2/2
✓ Branch 0 taken 7248 times.
✓ Branch 1 taken 2416 times.
9664 for(int32_t j=0; j<3; j++)
6115 {
6116
1/2
✓ Branch 0 taken 7248 times.
✗ Branch 1 not taken.
7248 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6117 return qe_invalid;
6118 7248 }
6119 2416 }
6120 208 }
6121
6122 802 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6123 802 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6124
6125 //v9 includes quest misc[32]
6126 // ... this has been deprecated (2024)
6127
2/2
✓ Branch 0 taken 594 times.
✓ Branch 1 taken 208 times.
802 if(s_version >= 9)
6128 {
6129
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 208 times.
6864 for ( int32_t q = 0; q < 32; q++ )
6130 {
6131
1/2
✓ Branch 0 taken 6656 times.
✗ Branch 1 not taken.
6656 if(!p_igetl(&temp_misc.questmisc[q],f))
6132 return qe_invalid;
6133 6656 }
6134 // this was string labels
6135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
208 if (pack_fseek(f, 32 * 128))
6136 return qe_invalid;
6137 208 }
6138
6139
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 594 times.
802 if(s_version >= 11 )
6140 {
6141
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6142 return qe_invalid;
6143 208 }
6144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 594 times.
594 else if(s_version < 11 )
6145 {
6146 594 temp_misc.zscript_last_compiled_version = -1;
6147 594 }
6148
6149 802 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6150
6151
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 594 times.
802 if(s_version >= 12)
6152 {
6153 byte spr;
6154
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 208 times.
53456 for(int32_t q = 0; q < sprMAX; ++q)
6155 {
6156
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if(!p_getc(&spr,f))
6157 return qe_invalid;
6158 53248 temp_misc.sprites[q] = spr;
6159 53248 }
6160 208 }
6161 else
6162 {
6163 594 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6164 //temp_misc.sprites[sprFALL] = ;
6165 }
6166
6167
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 594 times.
802 if(s_version >= 13)
6168 {
6169
2/2
✓ Branch 0 taken 13312 times.
✓ Branch 1 taken 208 times.
13520 for(size_t q = 0; q < 64; ++q)
6170 {
6171 13312 bottletype* bt = &(temp_misc.bottle_types[q]);
6172
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if (!p_getstr(bt->name, sizeof(bt->name)-1, f))
6173 return qe_invalid;
6174
2/2
✓ Branch 0 taken 39936 times.
✓ Branch 1 taken 13312 times.
53248 for(size_t j = 0; j < 3; ++j)
6175 {
6176
1/2
✓ Branch 0 taken 39936 times.
✗ Branch 1 not taken.
39936 if (!p_getc(&(bt->counter[j]), f))
6177 return qe_invalid;
6178
1/2
✓ Branch 0 taken 39936 times.
✗ Branch 1 not taken.
39936 if (!p_igetw(&(bt->amount[j]), f))
6179 return qe_invalid;
6180 39936 }
6181
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if (!p_getc(&(bt->flags), f))
6182 return qe_invalid;
6183
1/2
✓ Branch 0 taken 13312 times.
✗ Branch 1 not taken.
13312 if (!p_getc(&(bt->next_type), f))
6184 return qe_invalid;
6185 13312 }
6186
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 208 times.
53456 for(size_t q = 0; q < 256; ++q)
6187 {
6188 53248 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6189
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if (!pfread(bst->name, sizeof(bst->name)-1, f))
6190 return qe_invalid;
6191
2/2
✓ Branch 0 taken 159744 times.
✓ Branch 1 taken 53248 times.
212992 for(size_t j = 0; j < 3; ++j)
6192 {
6193
1/2
✓ Branch 0 taken 159744 times.
✗ Branch 1 not taken.
159744 if (!p_getc(&(bst->fill[j]), f))
6194 return qe_invalid;
6195
1/2
✓ Branch 0 taken 159744 times.
✗ Branch 1 not taken.
159744 if (!p_igetw(&(bst->comb[j]), f))
6196 return qe_invalid;
6197
1/2
✓ Branch 0 taken 159744 times.
✗ Branch 1 not taken.
159744 if (!p_getc(&(bst->cset[j]), f))
6198 return qe_invalid;
6199
1/2
✓ Branch 0 taken 159744 times.
✗ Branch 1 not taken.
159744 if (!p_igetw(&(bst->price[j]), f))
6200 return qe_invalid;
6201
1/2
✓ Branch 0 taken 159744 times.
✗ Branch 1 not taken.
159744 if (!p_igetw(&(bst->str[j]), f))
6202 return qe_invalid;
6203 159744 }
6204 53248 }
6205 208 }
6206 else
6207 {
6208
2/2
✓ Branch 0 taken 38016 times.
✓ Branch 1 taken 594 times.
38610 for(size_t q = 0; q < 64; ++q)
6209 38016 temp_misc.bottle_types[q].clear();
6210
2/2
✓ Branch 0 taken 152064 times.
✓ Branch 1 taken 594 times.
152658 for(size_t q = 0; q < 256; ++q)
6211 152064 temp_misc.bottle_shop_types[q].clear();
6212 }
6213
6214
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 594 times.
802 if(s_version >= 14)
6215 {
6216 byte msfx;
6217
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 208 times.
53456 for(int32_t q = 0; q < sfxMAX; ++q)
6218 {
6219
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if(!p_getc(&msfx,f))
6220 return qe_invalid;
6221 53248 temp_misc.miscsfx[q] = msfx;
6222 53248 }
6223 208 }
6224 else
6225 {
6226 594 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6227 594 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6228 594 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6229 }
6230
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 594 times.
802 if(s_version < 15)
6231 {
6232 594 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6233 594 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6234 594 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6235 594 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6236 594 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6237 594 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6238 594 }
6239
2/2
✓ Branch 0 taken 191 times.
✓ Branch 1 taken 611 times.
802 if(s_version < 16)
6240 {
6241 611 temp_misc.miscsfx[sfxTAP] = WAV_ZN1TAP;
6242 611 temp_misc.miscsfx[sfxTAP_HOLLOW] = WAV_ZN1TAP2;
6243 611 }
6244
6245
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 801 times.
802 if (!should_skip)
6246 801 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6247
6248 802 return 0;
6249 820 }
6250
6251 extern char *item_string[MAXITEMS];
6252 extern const char *old_item_string[iLast];
6253 extern char *weapon_string[MAXWPNS];
6254 extern const char *old_weapon_string[wLast];
6255
6256 491 int32_t readitems(PACKFILE *f, word version, word build)
6257 {
6258
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 24 times.
491 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_items);
6259
6260 byte padding;
6261 int32_t dummy;
6262 491 word items_to_read=MAXITEMS;
6263 491 itemdata tempitem;
6264 491 word s_version=0;
6265 word dummy_word;
6266
6267
2/2
✓ Branch 0 taken 485 times.
✓ Branch 1 taken 6 times.
491 if(version < 0x186)
6268 {
6269 6 items_to_read=64;
6270 6 }
6271
6272
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 467 times.
491 if(version > 0x192)
6273 {
6274 467 items_to_read=0;
6275
6276 //section version info
6277
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if(!p_igetw(&s_version,f))
6278 {
6279 return qe_invalid;
6280 }
6281
6282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if (s_version > V_ITEMS)
6283 return qe_version;
6284
6285 467 FFCore.quest_format[vItems] = s_version;
6286
6287
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if(!read_deprecated_section_cversion(f))
6288 {
6289 return qe_invalid;
6290 }
6291
6292 //section size
6293
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if(!p_igetl(&dummy,f))
6294 {
6295 return qe_invalid;
6296 }
6297
6298 //finally... section data
6299
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if(!p_igetw(&items_to_read,f))
6300 {
6301 return qe_invalid;
6302 }
6303
6304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if (items_to_read > MAXITEMS)
6305 {
6306 return qe_invalid;
6307 }
6308 467 }
6309
6310
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 83 times.
491 if(s_version>1)
6311 {
6312
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 408 times.
104856 for(int32_t i=0; i<items_to_read; i++)
6313 {
6314 char tempname[64];
6315
6316
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!pfread(tempname, 64, f))
6317 {
6318 return qe_invalid;
6319 }
6320
6321 104448 item_string[i][0] = '\0';
6322 104448 strncat(item_string[i], tempname, 64 - 1);
6323 104448 }
6324 408 }
6325
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
6326 {
6327
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
6328 {
6329 20992 reset_itemname(i);
6330 20992 }
6331 82 }
6332
6333
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 490 times.
491 if (!should_skip)
6334
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 490 times.
125930 for(int32_t i=0; i<MAXITEMS; i++)
6335 {
6336 125440 itemdata& id = itemsbuf[i];
6337 125440 memset(&id, 0, sizeof(itemdata));
6338 125440 id.count=-1;
6339 125440 id.playsound=WAV_SCALE;
6340 125440 reset_itembuf(&id,i);
6341 125930 }
6342
6343
2/2
✓ Branch 0 taken 113570 times.
✓ Branch 1 taken 491 times.
114061 for(int32_t i=0; i<items_to_read; i++)
6344 {
6345 113570 tempitem = itemdata();
6346 113570 reset_itembuf(&tempitem,i);
6347
6348
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 60322 times.
113570 if ( s_version > 35 ) //expanded tiles
6349 {
6350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53248 times.
53248 if(!p_igetl(&tempitem.tile,f))
6351 {
6352 return qe_invalid;
6353 }
6354 53248 }
6355 else
6356 {
6357
1/2
✓ Branch 0 taken 60322 times.
✗ Branch 1 not taken.
60322 if(!p_igetw(&tempitem.tile,f))
6358 {
6359 return qe_invalid;
6360 }
6361 }
6362
6363
1/2
✓ Branch 0 taken 113570 times.
✗ Branch 1 not taken.
113570 if(!p_getc(&tempitem.misc_flags,f))
6364 {
6365 return qe_invalid;
6366 }
6367
6368
1/2
✓ Branch 0 taken 113570 times.
✗ Branch 1 not taken.
113570 if(!p_getc(&tempitem.csets,f))
6369 {
6370 return qe_invalid;
6371 }
6372
6373
1/2
✓ Branch 0 taken 113570 times.
✗ Branch 1 not taken.
113570 if(!p_getc(&tempitem.frames,f))
6374 {
6375 return qe_invalid;
6376 }
6377
6378
1/2
✓ Branch 0 taken 113570 times.
✗ Branch 1 not taken.
113570 if(!p_getc(&tempitem.speed,f))
6379 {
6380 return qe_invalid;
6381 }
6382
6383
1/2
✓ Branch 0 taken 113570 times.
✗ Branch 1 not taken.
113570 if(!p_getc(&tempitem.delay,f))
6384 {
6385 return qe_invalid;
6386 }
6387
6388
2/2
✓ Branch 0 taken 108578 times.
✓ Branch 1 taken 4992 times.
113570 if(version < 0x193)
6389 {
6390
1/2
✓ Branch 0 taken 4992 times.
✗ Branch 1 not taken.
4992 if(!p_getc(&padding,f))
6391 {
6392 return qe_invalid;
6393 }
6394
6395
4/6
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3456 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✗ Branch 5 not taken.
4992 if((version < 0x192)||((version == 0x192)&&(build<186)))
6396 {
6397
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 4736 times.
4992 if (should_skip)
6398 256 continue;
6399
6400
3/3
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 4690 times.
✓ Branch 2 taken 23 times.
4736 switch(i)
6401 {
6402 case iShield:
6403 23 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6404 23 break;
6405
6406 case iMShield:
6407 23 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6408 23 break;
6409
6410 default:
6411 4690 tempitem.ltm=0;
6412 4690 break;
6413 }
6414
6415 4736 tempitem.count=-1;
6416 4736 tempitem.flags=item_none;
6417 4736 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6418 4736 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6419 4736 tempitem.type=0xFF;
6420 4736 tempitem.playsound=WAV_SCALE;
6421 4736 reset_itembuf(&tempitem,i);
6422
6423 4736 itemsbuf[i] = tempitem;
6424
6425 4736 continue;
6426 }
6427 }
6428
6429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108578 times.
108578 if(!p_igetl(&tempitem.ltm,f))
6430 {
6431 return qe_invalid;
6432 }
6433
6434
1/2
✓ Branch 0 taken 108578 times.
✗ Branch 1 not taken.
108578 if(version < 0x193)
6435 {
6436 for(int32_t q=0; q<12; q++)
6437 {
6438 if(!p_getc(&padding,f))
6439 {
6440 return qe_invalid;
6441 }
6442 }
6443 }
6444
6445
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 4130 times.
108578 if(s_version>1)
6446 {
6447
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 51200 times.
104448 if ( s_version >= 31 )
6448 {
6449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53248 times.
53248 if(!p_igetl(&tempitem.type,f))
6450 {
6451 return qe_invalid;
6452 }
6453 53248 }
6454 else
6455 {
6456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(!p_getc(&tempitem.type,f))
6457 {
6458 return qe_invalid;
6459 }
6460 }
6461
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(s_version < 16)
6462 if(tempitem.type == 0xFF)
6463 tempitem.type = itype_misc;
6464
6465
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!p_getc(&tempitem.level,f))
6466 {
6467 return qe_invalid;
6468 }
6469
6470
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(s_version>5)
6471 {
6472
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 51200 times.
104448 if(s_version>=31)
6473 {
6474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53248 times.
53248 if(!p_igetl(&tempitem.power,f))
6475 {
6476 return qe_invalid;
6477 }
6478 53248 }
6479 else
6480 {
6481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(!p_getc(&tempitem.power,f))
6482 {
6483 return qe_invalid;
6484 }
6485 }
6486
6487 //converted flags from 16b to 32b -Z
6488
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53248 times.
104448 if ( s_version < 41 )
6489 {
6490
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&tempitem.flags,f))
6491 {
6492 return qe_invalid;
6493 }
6494 51200 }
6495 else
6496 {
6497
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if(!p_igetl(&tempitem.flags,f))
6498 {
6499 return qe_invalid;
6500 }
6501 }
6502 104448 }
6503 else
6504 {
6505 //tempitem.power = tempitem.fam_type;
6506 char tempchar;
6507
6508 if(!p_getc(&tempchar,f))
6509 {
6510 return qe_invalid;
6511 }
6512
6513 if (tempchar) tempitem.flags |= item_gamedata;
6514 }
6515
6516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if(!p_igetw(&tempitem.script,f))
6517 {
6518 return qe_invalid;
6519 }
6520
6521
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(s_version<=3)
6522 {
6523 if(tempitem.script > NUMSCRIPTITEM)
6524 {
6525 tempitem.script = 0;
6526 }
6527 }
6528
6529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if(!p_getc(&tempitem.count,f))
6530 {
6531 return qe_invalid;
6532 }
6533
6534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if(!p_igetw(&tempitem.amount,f))
6535 {
6536 return qe_invalid;
6537 }
6538
6539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if(!p_igetw(&tempitem.collect_script,f))
6540 {
6541 return qe_invalid;
6542 }
6543
6544
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(s_version<=3)
6545 {
6546 if(tempitem.collect_script > NUMSCRIPTITEM)
6547 {
6548 tempitem.collect_script = 0;
6549 }
6550 }
6551
6552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if(!p_igetw(&tempitem.setmax,f))
6553 {
6554 return qe_invalid;
6555 }
6556
6557
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!p_igetw(&tempitem.max,f))
6558 {
6559 return qe_invalid;
6560 }
6561
6562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if(!p_getc(&tempitem.playsound,f))
6563 {
6564 return qe_invalid;
6565 }
6566
6567
2/2
✓ Branch 0 taken 835584 times.
✓ Branch 1 taken 104448 times.
940032 for(int32_t j=0; j<8; j++)
6568 {
6569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 835584 times.
835584 if(!p_igetl(&tempitem.initiald[j],f))
6570 {
6571 return qe_invalid;
6572 }
6573 835584 }
6574
6575
2/2
✓ Branch 0 taken 208896 times.
✓ Branch 1 taken 104448 times.
313344 for(int32_t j=0; j<2; j++)
6576 {
6577 byte temp;
6578
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_getc(&temp,f))
6579 {
6580 return qe_invalid;
6581 }
6582 208896 }
6583
6584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if(s_version>4)
6585 {
6586
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(s_version>5)
6587 {
6588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if(!p_getc(&tempitem.wpn,f))
6589 {
6590 return qe_invalid;
6591 }
6592
6593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if(!p_getc(&tempitem.wpn2,f))
6594 {
6595 return qe_invalid;
6596 }
6597
6598
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!p_getc(&tempitem.wpn3,f))
6599 {
6600 return qe_invalid;
6601 }
6602
6603
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!p_getc(&tempitem.wpn4,f))
6604 {
6605 return qe_invalid;
6606 }
6607
6608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if(s_version>=15)
6609 {
6610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if(!p_getc(&tempitem.wpn5,f))
6611 {
6612 return qe_invalid;
6613 }
6614
6615
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!p_getc(&tempitem.wpn6,f))
6616 {
6617 return qe_invalid;
6618 }
6619
6620
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!p_getc(&tempitem.wpn7,f))
6621 {
6622 return qe_invalid;
6623 }
6624
6625
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!p_getc(&tempitem.wpn8,f))
6626 {
6627 return qe_invalid;
6628 }
6629
6630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if(!p_getc(&tempitem.wpn9,f))
6631 {
6632 return qe_invalid;
6633 }
6634
6635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if(!p_getc(&tempitem.wpn10,f))
6636 {
6637 return qe_invalid;
6638 }
6639 104448 }
6640
6641
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!p_getc(&tempitem.pickup_hearts,f))
6642 {
6643 return qe_invalid;
6644 }
6645
6646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if(s_version<15)
6647 {
6648 if(!p_igetw(&dummy_word,f))
6649 {
6650 return qe_invalid;
6651 }
6652
6653 tempitem.misc1=dummy_word;
6654
6655 if(!p_igetw(&dummy_word,f))
6656 {
6657 return qe_invalid;
6658 }
6659
6660 tempitem.misc2=dummy_word;
6661 }
6662 else
6663 {
6664
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!p_igetl(&tempitem.misc1,f))
6665 {
6666 return qe_invalid;
6667 }
6668
6669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if(!p_igetl(&tempitem.misc2,f))
6670 {
6671 return qe_invalid;
6672 }
6673
6674 // Version 24: sh_ice -> sh_script; previously, all shields could block script weapons
6675
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(s_version<24)
6676 {
6677 if(tempitem.type==itype_shield)
6678 {
6679 tempitem.misc1|=sh_script;
6680 }
6681 }
6682 }
6683
6684
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53248 times.
104448 if(s_version < 53)
6685 {
6686 byte tempbyte;
6687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(!p_getc(&tempbyte,f))
6688 {
6689 return qe_invalid;
6690 }
6691 51200 tempitem.cost_amount[0] = tempbyte;
6692 51200 }
6693 else
6694 {
6695
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 53248 times.
159744 for(auto q = 0; q < 2; ++q)
6696 {
6697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106496 times.
106496 if(!p_igetw(&tempitem.cost_amount[q],f))
6698 {
6699 return qe_invalid;
6700 }
6701 106496 }
6702 }
6703 104448 }
6704 else
6705 {
6706 char tempchar;
6707
6708 if(!p_getc(&tempchar,f))
6709 {
6710 return qe_invalid;
6711 }
6712
6713 if (tempchar) tempitem.flags |= item_edible;
6714 }
6715
6716 // June 2007: more misc. attributes
6717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if(s_version>=12)
6718 {
6719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if(s_version<15)
6720 {
6721 if(!p_igetw(&dummy_word,f))
6722 {
6723 return qe_invalid;
6724 }
6725
6726 tempitem.misc3=dummy_word;
6727
6728 if(!p_igetw(&dummy_word,f))
6729 {
6730 return qe_invalid;
6731 }
6732
6733 tempitem.misc4=dummy_word;
6734 }
6735 else
6736 {
6737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if(!p_igetl(&tempitem.misc3,f))
6738 {
6739 return qe_invalid;
6740 }
6741
6742
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!p_igetl(&tempitem.misc4,f))
6743 {
6744 return qe_invalid;
6745 }
6746
6747
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!p_igetl(&tempitem.misc5,f))
6748 {
6749 return qe_invalid;
6750 }
6751
6752
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!p_igetl(&tempitem.misc6,f))
6753 {
6754 return qe_invalid;
6755 }
6756
6757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if(!p_igetl(&tempitem.misc7,f))
6758 {
6759 return qe_invalid;
6760 }
6761
6762
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!p_igetl(&tempitem.misc8,f))
6763 {
6764 return qe_invalid;
6765 }
6766
6767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104448 times.
104448 if(!p_igetl(&tempitem.misc9,f))
6768 {
6769 return qe_invalid;
6770 }
6771
6772
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!p_igetl(&tempitem.misc10,f))
6773 {
6774 return qe_invalid;
6775 }
6776 }
6777
6778
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!p_getc(&tempitem.usesound,f))
6779 {
6780 return qe_invalid;
6781 }
6782
6783
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 51200 times.
104448 if(s_version >= 49)
6784 {
6785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53248 times.
53248 if(!p_getc(&tempitem.usesound2,f))
6786 {
6787 return qe_invalid;
6788 }
6789 53248 }
6790 51200 else tempitem.usesound2 = 0;
6791
6792
3/4
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53248 times.
✓ Branch 2 taken 51200 times.
✗ Branch 3 not taken.
104448 if(s_version < 50 && tempitem.type == itype_mirror)
6793 {
6794 //Split continue/dmap warp effect/sfx, port for old
6795 tempitem.misc2 = tempitem.misc1;
6796 tempitem.usesound2 = tempitem.usesound;
6797 }
6798 104448 }
6799 104448 }
6800
6801
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53248 times.
104448 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6802 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6803
2/2
✓ Branch 0 taken 40192 times.
✓ Branch 1 taken 13056 times.
53248 if(s_version < 63)
6804 {
6805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13056 times.
13056 if(!p_getc(&tempitem.weap_data.imitate_weapon,f))
6806 {
6807 return qe_invalid;
6808 }
6809
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_getc(&tempitem.weap_data.default_defense,f))
6810 {
6811 return qe_invalid;
6812 }
6813 13056 }
6814
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if(!p_igetl(&tempitem.weaprange,f))
6815 {
6816 return qe_invalid;
6817 }
6818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53248 times.
53248 if(!p_igetl(&tempitem.weapduration,f))
6819 {
6820 return qe_invalid;
6821 }
6822
2/2
✓ Branch 0 taken 532480 times.
✓ Branch 1 taken 53248 times.
585728 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6823 {
6824
1/2
✓ Branch 0 taken 532480 times.
✗ Branch 1 not taken.
532480 if(!p_igetl(&tempitem.weap_pattern[q],f))
6825 {
6826 return qe_invalid;
6827 }
6828 532480 }
6829 53248 }
6830
6831
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53248 times.
104448 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6832 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53248 times.
53248 if(!p_igetl(&tempitem.duplicates,f))
6834 {
6835 return qe_invalid;
6836 }
6837
2/2
✓ Branch 0 taken 40192 times.
✓ Branch 1 taken 13056 times.
53248 if(s_version < 63)
6838
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 13056 times.
117504 for ( int32_t q = 0; q < INITIAL_D; q++ )
6839
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!p_igetl(&tempitem.weap_data.initd[q],f))
6840 13056 return qe_invalid;
6841
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 53248 times.
159744 for ( int32_t q = 0; q < 2; q++ )
6842 {
6843 byte temp;
6844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106496 times.
106496 if(!p_getc(&temp,f))
6845 {
6846 return qe_invalid;
6847 }
6848 106496 }
6849
6850
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if(!p_getc(&tempitem.drawlayer,f))
6851 {
6852 return qe_invalid;
6853 }
6854
6855
6856
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if(!p_igetl(&tempitem.hxofs,f))
6857 {
6858 return qe_invalid;
6859 }
6860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53248 times.
53248 if(!p_igetl(&tempitem.hyofs,f))
6861 {
6862 return qe_invalid;
6863 }
6864
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if(!p_igetl(&tempitem.hxsz,f))
6865 {
6866 return qe_invalid;
6867 }
6868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53248 times.
53248 if(!p_igetl(&tempitem.hysz,f))
6869 {
6870 return qe_invalid;
6871 }
6872
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if(!p_igetl(&tempitem.hzsz,f))
6873 {
6874 return qe_invalid;
6875 }
6876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53248 times.
53248 if(!p_igetl(&tempitem.xofs,f))
6877 {
6878 return qe_invalid;
6879 }
6880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53248 times.
53248 if(!p_igetl(&tempitem.yofs,f))
6881 {
6882 return qe_invalid;
6883 }
6884
2/2
✓ Branch 0 taken 40192 times.
✓ Branch 1 taken 13056 times.
53248 if(s_version < 63)
6885 {
6886
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_igetl(&tempitem.weap_data.hxofs,f))
6887 return qe_invalid;
6888
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_igetl(&tempitem.weap_data.hyofs,f))
6889 return qe_invalid;
6890
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_igetl(&tempitem.weap_data.hxsz,f))
6891 return qe_invalid;
6892
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_igetl(&tempitem.weap_data.hysz,f))
6893 return qe_invalid;
6894
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_igetl(&tempitem.weap_data.hzsz,f))
6895 return qe_invalid;
6896
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_igetl(&tempitem.weap_data.xofs,f))
6897 return qe_invalid;
6898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13056 times.
13056 if(!p_igetl(&tempitem.weap_data.yofs,f))
6899 return qe_invalid;
6900 13056 }
6901
2/2
✓ Branch 0 taken 40192 times.
✓ Branch 1 taken 13056 times.
53248 if(s_version < 63)
6902
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_igetw(&tempitem.weap_data.script,f))
6903 return qe_invalid;
6904
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if(!p_igetl(&tempitem.wpnsprite,f))
6905 {
6906 return qe_invalid;
6907 }
6908 53248 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6909
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 53248 times.
159744 for(auto q = 0; q < num_cost_tmr; ++q)
6910 {
6911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106496 times.
106496 if(!p_igetl(&tempitem.magiccosttimer[q],f))
6912 {
6913 return qe_invalid;
6914 }
6915 106496 }
6916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53248 times.
53248 for(auto q = num_cost_tmr; q < 2; ++q)
6917 tempitem.magiccosttimer[q] = 0;
6918 53248 }
6919
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53248 times.
104448 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6920 {
6921 //Item Size FLags, TileWidth, TileHeight
6922
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if(!p_igetl(&tempitem.overrideFLAGS,f))
6923 {
6924 return qe_invalid;
6925 }
6926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53248 times.
53248 if(!p_igetl(&tempitem.tilew,f))
6927 {
6928 return qe_invalid;
6929 }
6930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53248 times.
53248 if(!p_igetl(&tempitem.tileh,f))
6931 {
6932 return qe_invalid;
6933 }
6934 53248 }
6935
4/4
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 51200 times.
✓ Branch 2 taken 40192 times.
✓ Branch 3 taken 13056 times.
104448 if ( s_version >= 29 && s_version < 63) //! More new vars.
6936 {
6937
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_igetl(&tempitem.weap_data.override_flags,f))
6938 return qe_invalid;
6939
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_igetl(&tempitem.weap_data.tilew,f))
6940 return qe_invalid;
6941
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_igetl(&tempitem.weap_data.tileh,f))
6942 return qe_invalid;
6943 13056 }
6944
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53248 times.
104448 if ( s_version >= 30 ) //! More new vars.
6945 {
6946 //Pickup Type
6947
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if(!p_igetl(&tempitem.pickup,f))
6948 {
6949 return qe_invalid;
6950 }
6951 53248 }
6952
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53248 times.
104448 if ( s_version >= 32 ) //! More new vars.
6953 {
6954 //Pickup Type
6955
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if(!p_igetw(&tempitem.pstring,f))
6956 {
6957 return qe_invalid;
6958 }
6959 53248 }
6960
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53248 times.
104448 if ( s_version >= 33 ) //! More new vars.
6961 {
6962 //Pickup Type
6963
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if(!p_igetw(&tempitem.pickup_string_flags,f))
6964 {
6965 return qe_invalid;
6966 }
6967 53248 }
6968
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53248 times.
104448 if ( s_version >= 34 ) //! cost counter
6969 {
6970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53248 times.
53248 if(s_version < 53)
6971 {
6972 if(!p_getc(&tempitem.cost_counter[0],f))
6973 {
6974 return qe_invalid;
6975 }
6976 }
6977 else
6978 {
6979
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 53248 times.
159744 for(auto q = 0; q < 2; ++q)
6980 {
6981
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_getc(&tempitem.cost_counter[q],f))
6982 {
6983 return qe_invalid;
6984 }
6985 106496 }
6986 }
6987 53248 }
6988
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53248 times.
104448 if ( s_version >= 44 ) //! sprite scripts
6989 {
6990
2/2
✓ Branch 0 taken 425984 times.
✓ Branch 1 taken 53248 times.
479232 for ( int32_t q = 0; q < 8; q++ )
6991 {
6992
2/2
✓ Branch 0 taken 27688960 times.
✓ Branch 1 taken 425984 times.
28114944 for ( int32_t w = 0; w < 65; w++ )
6993 {
6994
1/2
✓ Branch 0 taken 27688960 times.
✗ Branch 1 not taken.
27688960 if(!p_getc(&(tempitem.initD_label[q][w]),f))
6995 {
6996 return qe_invalid;
6997 }
6998 27688960 }
6999
2/2
✓ Branch 0 taken 321536 times.
✓ Branch 1 taken 104448 times.
425984 if(s_version < 63)
7000
2/2
✓ Branch 0 taken 6789120 times.
✓ Branch 1 taken 104448 times.
6893568 for ( int32_t w = 0; w < 65; w++ )
7001
1/2
✓ Branch 0 taken 6789120 times.
✗ Branch 1 not taken.
6789120 if(!p_getc(&padding,f))
7002 104448 return qe_invalid;
7003
2/2
✓ Branch 0 taken 27688960 times.
✓ Branch 1 taken 425984 times.
28114944 for ( int32_t w = 0; w < 65; w++ )
7004 {
7005
1/2
✓ Branch 0 taken 27688960 times.
✗ Branch 1 not taken.
27688960 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
7006 {
7007 return qe_invalid;
7008 }
7009 27688960 }
7010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425984 times.
425984 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
7011 {
7012 return qe_invalid;
7013 }
7014
7015 425984 }
7016
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 53248 times.
159744 for ( int32_t q = 0; q < 2; q++ )
7017 {
7018 byte temp;
7019
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_getc(&temp,f))
7020 {
7021 return qe_invalid;
7022 }
7023 106496 }
7024 //Pickup Type
7025
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if(!p_igetw(&tempitem.sprite_script,f))
7026 {
7027 return qe_invalid;
7028 }
7029 53248 }
7030
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 53248 times.
104448 if ( s_version >= 48 ) //! pickup flags
7031 {
7032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53248 times.
53248 if(!p_getc(&(tempitem.pickupflag),f))
7033 {
7034 return qe_invalid;
7035 }
7036 53248 }
7037
2/2
✓ Branch 0 taken 54528 times.
✓ Branch 1 taken 49920 times.
104448 if ( s_version >= 57 )
7038 {
7039 49920 std::string str;
7040
2/4
✓ Branch 0 taken 49920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49920 times.
✗ Branch 3 not taken.
49920 if(!p_getcstr(&str,f))
7041 return qe_invalid;
7042 49920 strncpy(tempitem.display_name,str.c_str(),255);
7043
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 49920 times.
49920 }
7044 104448 }
7045 else
7046 {
7047 4130 tempitem.count=-1;
7048 4130 tempitem.type=itype_misc;
7049 4130 tempitem.flags=item_none;
7050 4130 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7051 4130 tempitem.playsound=WAV_SCALE;
7052 4130 reset_itembuf(&tempitem,i);
7053 }
7054
7055
4/4
✓ Branch 0 taken 48896 times.
✓ Branch 1 taken 59682 times.
✓ Branch 2 taken 40192 times.
✓ Branch 3 taken 8704 times.
108578 if(s_version >= 58 && s_version < 63)
7056 {
7057
2/2
✓ Branch 0 taken 43520 times.
✓ Branch 1 taken 8704 times.
52224 for(int q = 0; q < WPNSPR_MAX; ++q)
7058 {
7059
1/2
✓ Branch 0 taken 43520 times.
✗ Branch 1 not taken.
43520 if(!p_getc(&tempitem.weap_data.burnsprs[q],f))
7060 return qe_invalid;
7061
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 42240 times.
43520 if(s_version >= 59)
7062
1/2
✓ Branch 0 taken 42240 times.
✗ Branch 1 not taken.
42240 if(!p_getc(&tempitem.weap_data.light_rads[q],f))
7063 return qe_invalid;
7064 43520 }
7065 8704 }
7066
7067
2/2
✓ Branch 0 taken 66850 times.
✓ Branch 1 taken 41728 times.
108578 if ( s_version >= 60 )
7068 {
7069
2/2
✓ Branch 0 taken 37376 times.
✓ Branch 1 taken 4352 times.
41728 if ( s_version >= 65 )
7070 {
7071
1/2
✓ Branch 0 taken 37376 times.
✗ Branch 1 not taken.
37376 if(!p_igetw(&tempitem.pickup_litems,f))
7072 return qe_invalid;
7073 37376 }
7074 else
7075 {
7076
1/2
✓ Branch 0 taken 4352 times.
✗ Branch 1 not taken.
4352 if(!p_getc(&padding,f))
7077 return qe_invalid;
7078 4352 tempitem.pickup_litems = word(padding);
7079 }
7080
1/2
✓ Branch 0 taken 41728 times.
✗ Branch 1 not taken.
41728 if(!p_igetw(&tempitem.pickup_litem_level,f))
7081 return qe_invalid;
7082 41728 }
7083
7084
2/2
✓ Branch 0 taken 41728 times.
✓ Branch 1 taken 66850 times.
108578 if ( s_version >= 62 )
7085 {
7086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41728 times.
41728 if (!p_igetl(&tempitem.moveflags, f))
7087 return qe_invalid;
7088
2/2
✓ Branch 0 taken 40192 times.
✓ Branch 1 taken 1536 times.
41728 if(s_version < 63)
7089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if (!p_igetl(&tempitem.weap_data.moveflags, f))
7090 return qe_invalid;
7091 41728 }
7092 else
7093 {
7094 66850 tempitem.moveflags = (move_obeys_grav | move_can_pitfall);
7095
3/3
✓ Branch 0 taken 1924 times.
✓ Branch 1 taken 64625 times.
✓ Branch 2 taken 301 times.
66850 switch(tempitem.type)
7096 {
7097 case itype_divinefire:
7098
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 134 times.
301 if(!(tempitem.flags & item_flag3))
7099 134 break;
7100 [[fallthrough]];
7101 case itype_bomb: case itype_sbomb:
7102 case itype_bait: case itype_liftglove:
7103 case itype_candle: case itype_book:
7104 2091 tempitem.weap_data.moveflags = (move_obeys_grav | move_can_pitfall);
7105 2091 break;
7106 default:
7107 64625 tempitem.weap_data.moveflags = move_none;
7108 64625 break;
7109 }
7110 }
7111
7112
2/2
✓ Branch 0 taken 40192 times.
✓ Branch 1 taken 68386 times.
108578 if(s_version >= 63)
7113 {
7114
1/2
✓ Branch 0 taken 40192 times.
✗ Branch 1 not taken.
40192 if(auto ret = read_weap_data(tempitem.weap_data, f))
7115 return ret;
7116 40192 }
7117 else
7118 {
7119
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 68369 times.
68386 SETFLAG(tempitem.weap_data.wflags, WFLAG_UPDATE_IGNITE_SPRITE, tempitem.flags & item_burning_sprites);
7120
3/3
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 67692 times.
✓ Branch 2 taken 64 times.
68386 switch(tempitem.type)
7121 {
7122 case itype_liftglove:
7123 64 tempitem.weap_data.wflags = WFLAG_BREAK_WHEN_LANDING;
7124 64 break;
7125 case itype_bomb: case itype_sbomb:
7126 // Moving these over and removing them from itemdata
7127
2/2
✓ Branch 0 taken 607 times.
✓ Branch 1 taken 23 times.
630 if(tempitem.flags & item_flag3)
7128 23 tempitem.weap_data.wflags |= WFLAG_STOP_WHEN_LANDING;
7129
2/2
✓ Branch 0 taken 607 times.
✓ Branch 1 taken 23 times.
630 if(tempitem.flags & item_flag5)
7130 23 tempitem.weap_data.wflags |= WFLAG_STOP_WHEN_HIT_SOLID;
7131 630 tempitem.flags &= ~(item_flag3|item_flag5);
7132
2/2
✓ Branch 0 taken 613 times.
✓ Branch 1 taken 17 times.
630 if(tempitem.misc4)
7133 {
7134 17 tempitem.weap_data.lift_level = tempitem.misc4;
7135 17 tempitem.weap_data.lift_time = tempitem.misc5;
7136 17 tempitem.weap_data.lift_height = tempitem.misc6;
7137 17 tempitem.misc4 = 0;
7138 17 tempitem.misc5 = 0;
7139 17 tempitem.misc6 = 0;
7140 17 }
7141 630 break;
7142 }
7143 }
7144
7145
2/2
✓ Branch 0 taken 71202 times.
✓ Branch 1 taken 37376 times.
108578 if (s_version >= 64)
7146 {
7147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37376 times.
37376 if (!p_igetl(&tempitem.cooldown, f))
7148 return qe_invalid;
7149 37376 }
7150
7151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108578 times.
108578 if (!should_skip)
7152 {
7153
1/2
✓ Branch 0 taken 108578 times.
✗ Branch 1 not taken.
108578 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
7154 {
7155 tempitem.script = 0;
7156 tempitem.weap_data.script = 0;
7157 for(int q = 0; q < 8; ++q)
7158 {
7159 tempitem.initiald[q] = 0;
7160 tempitem.weap_data.initd[q] = 0;
7161 }
7162 }
7163 108578 itemsbuf[i] = tempitem;
7164 108578 }
7165 108578 }
7166
7167
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 490 times.
491 if (should_skip)
7168 1 return 0;
7169
7170 //////////////////////////////////////////////////////
7171 // Now do any updates because of new item additions
7172 // (These can't be done above because items_to_read
7173 // might be too low.)
7174 //////////////////////////////////////////////////////
7175
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 490 times.
125930 for(int32_t i=0; i<MAXITEMS; i++)
7176 {
7177 125440 tempitem = itemsbuf[i];
7178
7179 //Account for older quests that didn't have an actual item for the used letter
7180
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 104448 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
125440 if(s_version < 2 && i==iLetterUsed)
7181 {
7182 82 reset_itembuf(&tempitem, iLetterUsed);
7183 82 strcpy(item_string[i],old_item_string[i]);
7184 82 tempitem.tile = itemsbuf[iLetter].tile;
7185 82 tempitem.csets = itemsbuf[iLetter].csets;
7186 82 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7187 82 tempitem.frames = itemsbuf[iLetter].frames;
7188 82 tempitem.speed = itemsbuf[iLetter].speed;
7189 82 tempitem.ltm = itemsbuf[iLetter].ltm;
7190 82 }
7191
7192
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 20992 times.
125440 if(s_version < 3)
7193 {
7194
3/3
✓ Branch 0 taken 1804 times.
✓ Branch 1 taken 19106 times.
✓ Branch 2 taken 82 times.
20992 switch(i)
7195 {
7196 case iRocsFeather:
7197 case iHoverBoots:
7198 case iSpinScroll:
7199 case iL2SpinScroll:
7200 case iCrossScroll:
7201 case iQuakeScroll:
7202 case iL2QuakeScroll:
7203 case iWhispRing:
7204 case iL2WhispRing:
7205 case iChargeRing:
7206 case iL2ChargeRing:
7207 case iPerilScroll:
7208 case iWalletL3:
7209 case iQuiverL4:
7210 case iBombBagL4:
7211 case iBracelet:
7212 case iL2Bracelet:
7213 case iOldGlove:
7214 case iL2Ladder:
7215 case iWealthMedal:
7216 case iL2WealthMedal:
7217 case iL3WealthMedal:
7218 1804 reset_itembuf(&tempitem, i);
7219 1804 strcpy(item_string[i],old_item_string[i]);
7220 1804 break;
7221
7222 case iSShield:
7223 82 reset_itembuf(&tempitem, i);
7224 82 strcpy(item_string[i],old_item_string[i]);
7225 82 strcpy(item_string[iShield],old_item_string[iShield]);
7226 82 strcpy(item_string[iMShield],old_item_string[iMShield]);
7227 82 break;
7228 }
7229 20992 }
7230
7231
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 20992 times.
125440 if(s_version < 5)
7232 {
7233
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 20418 times.
20992 switch(i)
7234 {
7235 case iHeartRing:
7236 case iL2HeartRing:
7237 case iL3HeartRing:
7238 case iMagicRing:
7239 case iL2MagicRing:
7240 case iL3MagicRing:
7241 case iL4MagicRing:
7242 574 reset_itembuf(&tempitem, i);
7243 574 strcpy(item_string[i],old_item_string[i]);
7244 574 break;
7245 }
7246 20992 }
7247
7248
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 20992 times.
125440 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7249 {
7250
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(i!=iBPotion && i!=iRPotion)
7251
2/2
✓ Branch 0 taken 19304 times.
✓ Branch 1 taken 1524 times.
20828 if (get_bit(deprecated_rules,32)) tempitem.flags |= item_keep_old;
7252
7253
43/43
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 82 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 328 times.
✓ Branch 11 taken 17302 times.
✓ Branch 12 taken 82 times.
✓ Branch 13 taken 82 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
✓ Branch 16 taken 82 times.
✓ Branch 17 taken 82 times.
✓ Branch 18 taken 82 times.
✓ Branch 19 taken 82 times.
✓ Branch 20 taken 82 times.
✓ Branch 21 taken 82 times.
✓ Branch 22 taken 82 times.
✓ Branch 23 taken 82 times.
✓ Branch 24 taken 82 times.
✓ Branch 25 taken 82 times.
✓ Branch 26 taken 82 times.
✓ Branch 27 taken 82 times.
✓ Branch 28 taken 82 times.
✓ Branch 29 taken 82 times.
✓ Branch 30 taken 82 times.
✓ Branch 31 taken 82 times.
✓ Branch 32 taken 82 times.
✓ Branch 33 taken 82 times.
✓ Branch 34 taken 82 times.
✓ Branch 35 taken 82 times.
✓ Branch 36 taken 82 times.
✓ Branch 37 taken 82 times.
✓ Branch 38 taken 82 times.
✓ Branch 39 taken 82 times.
✓ Branch 40 taken 82 times.
✓ Branch 41 taken 82 times.
✓ Branch 42 taken 82 times.
20992 switch(i)
7254 {
7255 case iTriforce:
7256 82 tempitem.level=1;
7257 82 break;
7258
7259 case iBigTri:
7260 82 tempitem.level=0;
7261 82 break;
7262
7263 case iBombs:
7264 82 tempitem.level=i_bomb;
7265 82 tempitem.power=4;
7266 82 tempitem.wpn=wBOMB;
7267 82 tempitem.wpn2=wBOOM;
7268 82 tempitem.misc1 = 50;
7269
7270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7271
7272 82 break;
7273
7274 case iSBomb:
7275 82 tempitem.level=i_sbomb;
7276 82 tempitem.power=16;
7277 82 tempitem.wpn=wSBOMB;
7278 82 tempitem.wpn2=wSBOOM;
7279 82 tempitem.misc1 = 50;
7280
7281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7282
7283 82 break;
7284
7285 case iBook:
7286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7287 tempitem.wpn = wFIREMAGIC;
7288
7289 82 break;
7290
7291 case iSArrow:
7292 82 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7293 82 tempitem.power=4;
7294 82 tempitem.flags|=item_gamedata;
7295 82 tempitem.wpn=wSARROW;
7296 82 break;
7297
7298 case iGArrow:
7299 82 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7300 82 tempitem.power=8;
7301 82 tempitem.flags|=(item_gamedata|item_flag1);
7302 82 tempitem.wpn=wGARROW;
7303 82 break;
7304
7305 case iBrang:
7306 82 tempitem.power=0;
7307 82 tempitem.wpn=wBRANG;
7308 82 tempitem.misc1=36;
7309 82 break;
7310
7311 case iMBrang:
7312 82 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7313 82 tempitem.power=0;
7314 82 tempitem.wpn=wMBRANG;
7315 82 break;
7316
7317 case iFBrang:
7318 82 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7319 82 tempitem.power=2;
7320 82 tempitem.wpn=wFBRANG;
7321 82 break;
7322
7323 case iBoots:
7324 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7325 82 tempitem.power=7;
7326 82 break;
7327
7328 case iWand:
7329 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7330 82 tempitem.power=2;
7331 82 tempitem.wpn=wWAND;
7332 82 tempitem.wpn3=wMAGIC;
7333 82 break;
7334
7335 case iBCandle:
7336 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7337 82 tempitem.power=1;
7338 82 tempitem.flags|=(item_gamedata|item_flag1);
7339 82 tempitem.wpn3=wFIRE;
7340 82 break;
7341
7342 case iRCandle:
7343 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7344 82 tempitem.power=1;
7345 82 tempitem.wpn3=wFIRE;
7346 82 break;
7347
7348 case iSword:
7349 82 tempitem.power=1;
7350 82 tempitem.flags|= item_flag4 |item_flag2;
7351 82 tempitem.wpn=tempitem.wpn3=wSWORD;
7352 82 tempitem.wpn2=wSWORDSLASH;
7353 82 break;
7354
7355 case iWSword:
7356 82 tempitem.power=2;
7357 82 tempitem.flags|= item_flag4 |item_flag2;
7358 82 tempitem.wpn=tempitem.wpn3=wWSWORD;
7359 82 tempitem.wpn2=wWSWORDSLASH;
7360 82 break;
7361
7362 case iMSword:
7363 82 tempitem.power=4;
7364 82 tempitem.flags|= item_flag4 |item_flag2;
7365 82 tempitem.wpn=tempitem.wpn3=wMSWORD;
7366 82 tempitem.wpn2=wMSWORDSLASH;
7367 82 break;
7368
7369 case iXSword:
7370 82 tempitem.power=8;
7371 82 tempitem.flags|= item_flag4 |item_flag2;
7372 82 tempitem.wpn=tempitem.wpn3=wXSWORD;
7373 82 tempitem.wpn2=wXSWORDSLASH;
7374 82 break;
7375
7376 case iDivineProtection:
7377 82 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? item_flag1 : item_none;
7378 82 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? item_flag2 : item_none;
7379 82 tempitem.wpn=wDIVINEPROTECTION1A;
7380 82 tempitem.wpn2=wDIVINEPROTECTION1B;
7381 82 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7382 82 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7383 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7384 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7385 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7386 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7387 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7388 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7389 82 tempitem.misc1=512;
7390 82 tempitem.cost_amount[0]=64;
7391 82 break;
7392
7393 case iLens:
7394 82 tempitem.misc1=60;
7395 82 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? item_none : item_rupee_magic;
7396 82 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7397 82 break;
7398
7399 case iArrow:
7400 82 tempitem.power=2;
7401 82 tempitem.wpn=wARROW;
7402 82 break;
7403
7404 case iHoverBoots:
7405 82 tempitem.misc1=45;
7406 82 tempitem.wpn=iwHover;
7407 82 break;
7408
7409 case iDivineFire:
7410 82 tempitem.power=8;
7411 82 tempitem.wpn=wDIVINEFIRE1A;
7412 82 tempitem.wpn2=wDIVINEFIRE1B;
7413 82 tempitem.wpn3=wDIVINEFIRES1A;
7414 82 tempitem.wpn4=wDIVINEFIRES1B;
7415 82 tempitem.misc1 = 32;
7416 82 tempitem.misc2 = 200;
7417 82 tempitem.cost_amount[0]=32;
7418 82 break;
7419
7420 case iDivineEscape:
7421 82 tempitem.cost_amount[0]=32;
7422 82 break;
7423
7424 case iHookshot:
7425 82 tempitem.power=0;
7426 82 tempitem.flags&=~item_flag1;
7427 82 tempitem.wpn=wHSHEAD;
7428 82 tempitem.wpn2=wHSCHAIN_H;
7429 82 tempitem.wpn4=wHSHANDLE;
7430 82 tempitem.wpn3=wHSCHAIN_V;
7431 82 tempitem.misc1=50;
7432 82 tempitem.misc2=100;
7433 82 break;
7434
7435 case iLongshot:
7436 82 tempitem.power=0;
7437 82 tempitem.flags&=~item_flag1;
7438 82 tempitem.wpn=wLSHEAD;
7439 82 tempitem.wpn2=wLSCHAIN_H;
7440 82 tempitem.wpn4=wLSHANDLE;
7441 82 tempitem.wpn3=wLSCHAIN_V;
7442 82 tempitem.misc1=99;
7443 82 tempitem.misc2=100;
7444 82 break;
7445
7446 case iHammer:
7447 82 tempitem.power=4;
7448 82 tempitem.wpn=wHAMMER;
7449 82 tempitem.wpn2=iwHammerSmack;
7450 82 break;
7451
7452 case iCByrna:
7453 82 tempitem.power=1;
7454 82 tempitem.wpn=wCBYRNA;
7455 82 tempitem.wpn2=wCBYRNASLASH;
7456 82 tempitem.wpn3=wCBYRNAORB;
7457 82 tempitem.misc1=4;
7458 82 tempitem.misc2=16;
7459 82 tempitem.misc3=1;
7460 82 tempitem.cost_amount[0]=1;
7461 82 break;
7462
7463 case iWhistle:
7464 82 tempitem.wpn=wWIND;
7465 82 tempitem.misc1=3;
7466 82 tempitem.flags|=item_flag1;
7467 82 break;
7468
7469 case iBRing:
7470 82 tempitem.power=2;
7471 82 tempitem.misc1=spBLUE;
7472 82 break;
7473
7474 case iRRing:
7475 82 tempitem.power=4;
7476 82 tempitem.misc1=spRED;
7477 82 break;
7478
7479 case iGRing:
7480 82 tempitem.power=8;
7481 82 tempitem.misc1=spGOLD;
7482 82 break;
7483
7484 case iSpinScroll:
7485 82 tempitem.power = 2;
7486 82 tempitem.misc1 = 1;
7487 82 break;
7488
7489 case iL2SpinScroll:
7490 82 tempitem.type=itype_spinscroll2;
7491 82 tempitem.level=1;
7492 82 tempitem.cost_amount[0]=8;
7493 82 tempitem.power=2;
7494 82 tempitem.misc1 = 20;
7495 82 break;
7496
7497 case iQuakeScroll:
7498 82 tempitem.misc1=0x10;
7499 82 tempitem.misc2=64;
7500 82 break;
7501
7502 case iL2QuakeScroll:
7503 82 tempitem.type=itype_quakescroll2;
7504 82 tempitem.level=1;
7505 82 tempitem.power = 2;
7506 82 tempitem.misc1=0x20;
7507 82 tempitem.misc2=192;
7508 82 tempitem.cost_amount[0]=8;
7509 82 break;
7510
7511 case iChargeRing:
7512 82 tempitem.misc1=64;
7513 82 tempitem.misc2=128;
7514 82 break;
7515
7516 case iL2ChargeRing:
7517 82 tempitem.misc1=32;
7518 82 tempitem.misc2=64;
7519 82 break;
7520
7521 case iOldGlove:
7522 82 tempitem.flags |= item_flag1;
7523
7524 //fallthrough
7525 case iBombBagL4:
7526 case iWalletL3:
7527 case iQuiverL4:
7528 case iBracelet:
7529 410 tempitem.power = 1;
7530 410 break;
7531
7532 case iL2Bracelet:
7533 82 tempitem.power = 2;
7534 82 break;
7535
7536 case iMKey:
7537 82 tempitem.power=0xFF;
7538 82 tempitem.flags |= item_flag1;
7539 82 break;
7540 }
7541 20992 }
7542
7543
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 20992 times.
125440 if(s_version < 7)
7544 {
7545
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 20664 times.
20992 switch(i)
7546 {
7547 case iStoneAgony:
7548 case iStompBoots:
7549 case iPerilRing:
7550 case iWhimsicalRing:
7551 {
7552 328 reset_itembuf(&tempitem, i);
7553 328 strcpy(item_string[i],old_item_string[i]);
7554 328 break;
7555 }
7556 }
7557 20992 }
7558
7559
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 20992 times.
125440 if(s_version < 8) // May 2007: Some corrections.
7560 {
7561
7/7
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 20336 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
20992 switch(i)
7562 {
7563 case iMShield:
7564 82 tempitem.misc1|=sh_flame;
7565 82 tempitem.misc2|=sh_fireball|sh_magic;
7566
7567
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(get_qr(qr_SWORDMIRROR))
7568 {
7569 tempitem.misc2 |= sh_sword;
7570 }
7571
7572 // fallthrough
7573 case iShield:
7574 164 tempitem.misc1|=sh_fireball|sh_sword|sh_magic;
7575
7576 // fallthrough
7577 case iSShield:
7578 246 tempitem.misc1|=sh_rock|sh_arrow|sh_brang|sh_script;
7579
7580
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7581 {
7582 tempitem.misc2 |= sh_rock;
7583 }
7584
7585 246 break;
7586
7587 case iWhispRing:
7588 82 tempitem.power=1;
7589 82 tempitem.flags|=item_gamedata|item_flag1;
7590 82 tempitem.misc1 = 3;
7591 82 break;
7592
7593 case iL2WhispRing:
7594 82 tempitem.power=0;
7595 82 tempitem.flags|=item_gamedata|item_flag1;
7596 82 tempitem.misc1 = 3;
7597 82 break;
7598
7599 case iL2Ladder:
7600 case iBow:
7601 case iCByrna:
7602 246 tempitem.power = 1;
7603 246 break;
7604 }
7605 20992 }
7606
7607
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 104448 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
125440 if(s_version < 9 && i==iClock)
7608 {
7609 82 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7610 82 }
7611
7612 //add the misc flag for bomb
7613
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 104448 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
125440 if(s_version < 10 && tempitem.type == itype_bomb)
7614 {
7615 82 tempitem.flags = (tempitem.flags & ~item_flag1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? item_flag1 : item_none);
7616 82 }
7617
7618
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 104448 times.
✓ Branch 2 taken 20828 times.
✓ Branch 3 taken 164 times.
125440 if(s_version < 11 && tempitem.type == itype_triforcepiece)
7619 {
7620 164 tempitem.flags = (tempitem.level ? item_gamedata : item_none);
7621 164 tempitem.playsound = (tempitem.level ? WAV_SCALE : WAV_CLEARED);
7622 164 }
7623
7624
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 20992 times.
125440 if(s_version < 12) // June 2007: More Misc. attributes.
7625 {
7626
5/5
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20582 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
20992 switch(i)
7627 {
7628 case iFBrang:
7629 82 tempitem.misc4 |= sh_fireball|sh_sword|sh_magic;
7630
7631 //fallthrough
7632 case iMBrang:
7633 164 tempitem.misc3 |= sh_sword|sh_magic;
7634
7635 //fallthrough
7636 case iHookshot:
7637 case iLongshot:
7638 //fallthrough
7639 328 tempitem.misc3 |= sh_fireball;
7640
7641 case iBrang:
7642 410 tempitem.misc3 |= sh_brang|sh_rock|sh_arrow;
7643 410 break;
7644 }
7645
7646
16/16
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 246 times.
✓ Branch 4 taken 164 times.
✓ Branch 5 taken 246 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 82 times.
✓ Branch 9 taken 328 times.
✓ Branch 10 taken 164 times.
✓ Branch 11 taken 9629 times.
✓ Branch 12 taken 246 times.
✓ Branch 13 taken 9313 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
20992 switch(tempitem.type)
7647 {
7648 case itype_hoverboots:
7649 82 tempitem.usesound = WAV_ZN1HOVER;
7650 82 break;
7651
7652 case itype_wand:
7653 82 tempitem.usesound = WAV_WAND;
7654 82 break;
7655
7656 case itype_book:
7657 82 tempitem.usesound = WAV_FIRE;
7658 82 break;
7659
7660 case itype_arrow:
7661 246 tempitem.usesound = WAV_ARROW;
7662 246 break;
7663
7664 case itype_hookshot:
7665 164 tempitem.usesound = WAV_HOOKSHOT;
7666 164 break;
7667
7668 case itype_brang:
7669 246 tempitem.usesound = WAV_BRANG;
7670 246 break;
7671
7672 case itype_shield:
7673 246 tempitem.usesound = WAV_CHINK;
7674 246 break;
7675
7676 case itype_sword:
7677 9313 tempitem.usesound = WAV_SWORD;
7678 9313 break;
7679
7680 case itype_whistle:
7681 82 tempitem.usesound = WAV_WHISTLE;
7682 82 break;
7683
7684 case itype_hammer:
7685 82 tempitem.usesound = WAV_HAMMER;
7686 82 break;
7687
7688 case itype_divinefire:
7689 82 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7690 82 break;
7691
7692 case itype_divineescape:
7693 82 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7694 82 break;
7695
7696 case itype_divineprotection:
7697 82 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7698 82 break;
7699
7700 case itype_bomb:
7701 case itype_sbomb:
7702 case itype_quakescroll:
7703 case itype_quakescroll2:
7704 328 tempitem.usesound = WAV_BOMB;
7705 328 break;
7706
7707 case itype_spinscroll:
7708 case itype_spinscroll2:
7709 164 tempitem.usesound = WAV_ZN1SPINATTACK;
7710 164 break;
7711 }
7712 20992 }
7713
7714
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 20992 times.
125440 if(s_version < 13) // July 2007
7715 {
7716
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.type == itype_whistle)
7717 {
7718 82 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7719 82 tempitem.power = 1;
7720 82 tempitem.flags|=item_flag1;
7721 82 }
7722
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.type == itype_wand)
7723 82 tempitem.flags|=item_flag1;
7724
2/2
✓ Branch 0 taken 20746 times.
✓ Branch 1 taken 82 times.
20828 else if(tempitem.type == itype_book)
7725 {
7726 82 tempitem.flags|=item_flag1;
7727 82 tempitem.power = 2;
7728 82 }
7729 20992 }
7730
7731
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 20992 times.
125440 if(s_version < 14) // August 2007
7732 {
7733
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
20992 if(tempitem.type == itype_fairy)
7734 {
7735 164 tempitem.usesound = WAV_SCALE;
7736
7737
1/2
✓ Branch 0 taken 164 times.
✗ Branch 1 not taken.
164 if(tempitem.level)
7738 164 tempitem.misc3=50;
7739 164 }
7740
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.type == itype_potion)
7741 {
7742 164 tempitem.flags |= item_gain_old;
7743 164 }
7744 20992 }
7745
7746
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 20992 times.
125440 if(s_version < 17) // November 2007
7747 {
7748
3/4
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
✓ Branch 2 taken 164 times.
✗ Branch 3 not taken.
20992 if(tempitem.type == itype_candle && !tempitem.wpn3)
7749 {
7750 tempitem.wpn3 = wFIRE;
7751 }
7752
4/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 20746 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 82 times.
20992 else if(tempitem.type == itype_arrow && tempitem.power>4)
7753 {
7754 82 tempitem.flags|=item_flag1;
7755 82 }
7756 20992 }
7757
7758
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 20992 times.
125440 if(s_version < 18) // New Year's Eve 2007
7759 {
7760
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.type == itype_whistle)
7761 82 tempitem.misc2 = 8; // Use the Whistle warp ring
7762
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.type == itype_bait)
7763 82 tempitem.misc1 = 768; // Frames until it goes
7764
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.type == itype_triforcepiece)
7765 {
7766
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
164 if(tempitem.flags & item_gamedata)
7767 {
7768 82 tempitem.misc2 = 1; // Cutscene 1
7769 82 tempitem.flags |= item_flag1; // Side Warp Out
7770 82 }
7771 164 }
7772 20992 }
7773
7774
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 20992 times.
125440 if(s_version < 19) // January 2008
7775 {
7776
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.type == itype_divineprotection)
7777 {
7778
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 80 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)) tempitem.flags |= item_flag3;
7779
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 72 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)) tempitem.flags |= item_flag4;
7780 82 }
7781 20992 }
7782
7783
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 20992 times.
125440 if(s_version < 20) // October 2008
7784 {
7785
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.type == itype_divineprotection)
7786 {
7787 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7788 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7789 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7790 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7791 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7792 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7793 82 }
7794 20992 }
7795
7796
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 20992 times.
125440 if(s_version < 21) // November 2008
7797 {
7798
1/2
✓ Branch 0 taken 20992 times.
✗ Branch 1 not taken.
20992 if(tempitem.flags & 0x0100) // item_slash
7799 {
7800 tempitem.flags &= ~item_unused;
7801
7802 if(tempitem.type == itype_sword ||
7803 tempitem.type == itype_wand ||
7804 tempitem.type == itype_candle ||
7805 tempitem.type == itype_cbyrna)
7806 {
7807 tempitem.flags |= item_flag4;
7808 }
7809 }
7810 20992 }
7811
7812
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 20992 times.
125440 if(s_version < 22) // September 2009
7813 {
7814
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(tempitem.type == itype_sbomb || tempitem.type == itype_bomb)
7815 {
7816 164 tempitem.misc3 = tempitem.power/2;
7817 164 }
7818 20992 }
7819
7820
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 20992 times.
125440 if(s_version < 23) // March 2011
7821 {
7822
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.type == itype_divinefire)
7823 82 tempitem.wpn5 = wFIRE;
7824
2/2
✓ Branch 0 taken 20828 times.
✓ Branch 1 taken 82 times.
20910 else if(tempitem.type == itype_book)
7825 82 tempitem.wpn2 = wFIRE;
7826 20992 }
7827
7828 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7829 // whether it was or not, and a lot of existing quests depended on the
7830 // incorrect behavior.
7831
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 20992 times.
125440 if(s_version < 25) // January 2012
7832 {
7833
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 328 times.
20992 if(tempitem.type == itype_bombbag)
7834 328 tempitem.flags |= item_flag1;
7835
7836
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.type == itype_divinefire)
7837 82 tempitem.flags |= item_flag3; // Sideview gravity flag
7838 20992 }
7839
7840
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 72192 times.
125440 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7841 {
7842
60/60
✓ Branch 0 taken 17547 times.
✓ Branch 1 taken 844 times.
✓ Branch 2 taken 831 times.
✓ Branch 3 taken 600 times.
✓ Branch 4 taken 327 times.
✓ Branch 5 taken 282 times.
✓ Branch 6 taken 558 times.
✓ Branch 7 taken 614 times.
✓ Branch 8 taken 297 times.
✓ Branch 9 taken 917 times.
✓ Branch 10 taken 892 times.
✓ Branch 11 taken 557 times.
✓ Branch 12 taken 858 times.
✓ Branch 13 taken 558 times.
✓ Branch 14 taken 279 times.
✓ Branch 15 taken 558 times.
✓ Branch 16 taken 295 times.
✓ Branch 17 taken 279 times.
✓ Branch 18 taken 846 times.
✓ Branch 19 taken 282 times.
✓ Branch 20 taken 285 times.
✓ Branch 21 taken 560 times.
✓ Branch 22 taken 255 times.
✓ Branch 23 taken 282 times.
✓ Branch 24 taken 279 times.
✓ Branch 25 taken 279 times.
✓ Branch 26 taken 279 times.
✓ Branch 27 taken 295 times.
✓ Branch 28 taken 281 times.
✓ Branch 29 taken 282 times.
✓ Branch 30 taken 279 times.
✓ Branch 31 taken 284 times.
✓ Branch 32 taken 558 times.
✓ Branch 33 taken 1116 times.
✓ Branch 34 taken 780 times.
✓ Branch 35 taken 279 times.
✓ Branch 36 taken 545 times.
✓ Branch 37 taken 1116 times.
✓ Branch 38 taken 279 times.
✓ Branch 39 taken 279 times.
✓ Branch 40 taken 279 times.
✓ Branch 41 taken 279 times.
✓ Branch 42 taken 279 times.
✓ Branch 43 taken 561 times.
✓ Branch 44 taken 558 times.
✓ Branch 45 taken 279 times.
✓ Branch 46 taken 840 times.
✓ Branch 47 taken 843 times.
✓ Branch 48 taken 1128 times.
✓ Branch 49 taken 279 times.
✓ Branch 50 taken 279 times.
✓ Branch 51 taken 279 times.
✓ Branch 52 taken 279 times.
✓ Branch 53 taken 279 times.
✓ Branch 54 taken 306 times.
✓ Branch 55 taken 10652 times.
✓ Branch 56 taken 2872 times.
✓ Branch 57 taken 842 times.
✓ Branch 58 taken 3261 times.
✓ Branch 59 taken 11005 times.
72192 switch(tempitem.type)
7843 {
7844 case itype_sword:
7845 {
7846 17547 tempitem.flags &= ~(item_flag5);
7847 17547 tempitem.misc3 = 0;
7848 17547 tempitem.misc4 = 0;
7849 17547 tempitem.misc5 = 0;
7850 17547 tempitem.misc6 = 0;
7851 17547 tempitem.misc7 = 0;
7852 17547 tempitem.misc8 = 0;
7853 17547 tempitem.misc9 = 0;
7854 17547 tempitem.misc10 = 0;
7855 17547 tempitem.wpn4 = 0;
7856 17547 tempitem.wpn5 = 0;
7857 17547 tempitem.wpn6 = 0;
7858 17547 tempitem.wpn7 = 0;
7859 17547 tempitem.wpn8 = 0;
7860 17547 tempitem.wpn9 = 0;
7861 17547 tempitem.wpn10 = 0;
7862 17547 break;
7863 }
7864 case itype_brang:
7865 {
7866 844 tempitem.flags &= ~(item_flag4 | item_flag5);
7867 844 tempitem.misc2 = 0;
7868 844 tempitem.misc5 = 0;
7869 844 tempitem.misc6 = 0;
7870 844 tempitem.misc7 = 0;
7871 844 tempitem.misc8 = 0;
7872 844 tempitem.misc9 = 0;
7873 844 tempitem.misc10 = 0;
7874 844 tempitem.wpn4 = 0;
7875 844 tempitem.wpn5 = 0;
7876 844 tempitem.wpn6 = 0;
7877 844 tempitem.wpn7 = 0;
7878 844 tempitem.wpn8 = 0;
7879 844 tempitem.wpn9 = 0;
7880 844 tempitem.wpn10 = 0;
7881 844 break;
7882 }
7883 case itype_arrow:
7884 {
7885 831 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7886 831 tempitem.misc2 = 0;
7887 831 tempitem.misc3 = 0;
7888 831 tempitem.misc4 = 0;
7889 831 tempitem.misc5 = 0;
7890 831 tempitem.misc6 = 0;
7891 831 tempitem.misc7 = 0;
7892 831 tempitem.misc8 = 0;
7893 831 tempitem.misc9 = 0;
7894 831 tempitem.misc10 = 0;
7895 831 tempitem.wpn4 = 0;
7896 831 tempitem.wpn5 = 0;
7897 831 tempitem.wpn6 = 0;
7898 831 tempitem.wpn7 = 0;
7899 831 tempitem.wpn8 = 0;
7900 831 tempitem.wpn9 = 0;
7901 831 tempitem.wpn10 = 0;
7902 831 break;
7903 }
7904 case itype_candle:
7905 {
7906 600 tempitem.flags &= ~ (item_flag3 | item_flag5);
7907 600 tempitem.misc1 = 0;
7908 600 tempitem.misc2 = 0;
7909 600 tempitem.misc3 = 0;
7910 600 tempitem.misc4 = 0;
7911 600 tempitem.misc5 = 0;
7912 600 tempitem.misc6 = 0;
7913 600 tempitem.misc7 = 0;
7914 600 tempitem.misc8 = 0;
7915 600 tempitem.misc9 = 0;
7916 600 tempitem.misc10 = 0;
7917 600 tempitem.wpn4 = 0;
7918 600 tempitem.wpn5 = 0;
7919 600 tempitem.wpn6 = 0;
7920 600 tempitem.wpn7 = 0;
7921 600 tempitem.wpn8 = 0;
7922 600 tempitem.wpn9 = 0;
7923 600 tempitem.wpn10 = 0;
7924 600 break;
7925 }
7926 case itype_whistle:
7927 {
7928 327 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7929 327 tempitem.misc3 = 0;
7930 327 tempitem.misc4 = 0;
7931 327 tempitem.misc5 = 0;
7932 327 tempitem.misc6 = 0;
7933 327 tempitem.misc7 = 0;
7934 327 tempitem.misc8 = 0;
7935 327 tempitem.misc9 = 0;
7936 327 tempitem.misc10 = 0;
7937 327 tempitem.wpn2 = 0;
7938 327 tempitem.wpn3 = 0;
7939 327 tempitem.wpn4 = 0;
7940 327 tempitem.wpn5 = 0;
7941 327 tempitem.wpn6 = 0;
7942 327 tempitem.wpn7 = 0;
7943 327 tempitem.wpn8 = 0;
7944 327 tempitem.wpn9 = 0;
7945 327 tempitem.wpn10 = 0;
7946 327 break;
7947 }
7948 case itype_bait:
7949 {
7950 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7951 282 tempitem.misc2 = 0;
7952 282 tempitem.misc3 = 0;
7953 282 tempitem.misc4 = 0;
7954 282 tempitem.misc5 = 0;
7955 282 tempitem.misc6 = 0;
7956 282 tempitem.misc7 = 0;
7957 282 tempitem.misc8 = 0;
7958 282 tempitem.misc9 = 0;
7959 282 tempitem.misc10 = 0;
7960 282 tempitem.wpn2 = 0;
7961 282 tempitem.wpn3 = 0;
7962 282 tempitem.wpn4 = 0;
7963 282 tempitem.wpn5 = 0;
7964 282 tempitem.wpn6 = 0;
7965 282 tempitem.wpn7 = 0;
7966 282 tempitem.wpn8 = 0;
7967 282 tempitem.wpn9 = 0;
7968 282 tempitem.wpn10 = 0;
7969 282 break;
7970 }
7971 case itype_letter:
7972 {
7973 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7974 558 tempitem.misc1 = 0;
7975 558 tempitem.misc2 = 0;
7976 558 tempitem.misc3 = 0;
7977 558 tempitem.misc4 = 0;
7978 558 tempitem.misc5 = 0;
7979 558 tempitem.misc6 = 0;
7980 558 tempitem.misc7 = 0;
7981 558 tempitem.misc8 = 0;
7982 558 tempitem.misc9 = 0;
7983 558 tempitem.misc10 = 0;
7984 558 tempitem.wpn = 0;
7985 558 tempitem.wpn2 = 0;
7986 558 tempitem.wpn3 = 0;
7987 558 tempitem.wpn4 = 0;
7988 558 tempitem.wpn5 = 0;
7989 558 tempitem.wpn6 = 0;
7990 558 tempitem.wpn7 = 0;
7991 558 tempitem.wpn8 = 0;
7992 558 tempitem.wpn9 = 0;
7993 558 tempitem.wpn10 = 0;
7994 558 break;
7995 }
7996 case itype_potion:
7997 {
7998 614 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
7999 614 tempitem.misc3 = 0;
8000 614 tempitem.misc4 = 0;
8001 614 tempitem.misc5 = 0;
8002 614 tempitem.misc6 = 0;
8003 614 tempitem.misc7 = 0;
8004 614 tempitem.misc8 = 0;
8005 614 tempitem.misc9 = 0;
8006 614 tempitem.misc10 = 0;
8007 614 tempitem.wpn = 0;
8008 614 tempitem.wpn2 = 0;
8009 614 tempitem.wpn3 = 0;
8010 614 tempitem.wpn4 = 0;
8011 614 tempitem.wpn5 = 0;
8012 614 tempitem.wpn6 = 0;
8013 614 tempitem.wpn7 = 0;
8014 614 tempitem.wpn8 = 0;
8015 614 tempitem.wpn9 = 0;
8016 614 tempitem.wpn10 = 0;
8017 614 break;
8018 }
8019 case itype_wand:
8020 {
8021 297 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
8022 297 tempitem.misc1 = 0;
8023 297 tempitem.misc2 = 0;
8024 297 tempitem.misc3 = 0;
8025 297 tempitem.misc4 = 0;
8026 297 tempitem.misc5 = 0;
8027 297 tempitem.misc6 = 0;
8028 297 tempitem.misc7 = 0;
8029 297 tempitem.misc8 = 0;
8030 297 tempitem.misc9 = 0;
8031 297 tempitem.misc10 = 0;
8032 297 tempitem.wpn4 = 0;
8033 297 tempitem.wpn5 = 0;
8034 297 tempitem.wpn6 = 0;
8035 297 tempitem.wpn7 = 0;
8036 297 tempitem.wpn8 = 0;
8037 297 tempitem.wpn9 = 0;
8038 297 tempitem.wpn10 = 0;
8039 297 break;
8040 }
8041 case itype_ring:
8042 {
8043 917 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8044 917 tempitem.misc2 = 0;
8045 917 tempitem.misc3 = 0;
8046 917 tempitem.misc4 = 0;
8047 917 tempitem.misc5 = 0;
8048 917 tempitem.misc6 = 0;
8049 917 tempitem.misc7 = 0;
8050 917 tempitem.misc8 = 0;
8051 917 tempitem.misc9 = 0;
8052 917 tempitem.misc10 = 0;
8053 917 tempitem.wpn = 0;
8054 917 tempitem.wpn2 = 0;
8055 917 tempitem.wpn3 = 0;
8056 917 tempitem.wpn4 = 0;
8057 917 tempitem.wpn5 = 0;
8058 917 tempitem.wpn6 = 0;
8059 917 tempitem.wpn7 = 0;
8060 917 tempitem.wpn8 = 0;
8061 917 tempitem.wpn9 = 0;
8062 917 tempitem.wpn10 = 0;
8063 917 break;
8064 }
8065 case itype_wallet:
8066 {
8067 892 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8068 892 tempitem.misc3 = 0;
8069 892 tempitem.misc4 = 0;
8070 892 tempitem.misc5 = 0;
8071 892 tempitem.misc6 = 0;
8072 892 tempitem.misc7 = 0;
8073 892 tempitem.misc8 = 0;
8074 892 tempitem.misc9 = 0;
8075 892 tempitem.misc10 = 0;
8076 892 tempitem.wpn = 0;
8077 892 tempitem.wpn2 = 0;
8078 892 tempitem.wpn3 = 0;
8079 892 tempitem.wpn4 = 0;
8080 892 tempitem.wpn5 = 0;
8081 892 tempitem.wpn6 = 0;
8082 892 tempitem.wpn7 = 0;
8083 892 tempitem.wpn8 = 0;
8084 892 tempitem.wpn9 = 0;
8085 892 tempitem.wpn10 = 0;
8086 892 break;
8087 }
8088 case itype_amulet:
8089 {
8090 557 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8091 557 tempitem.misc1 = 0;
8092 557 tempitem.misc2 = 0;
8093 557 tempitem.misc3 = 0;
8094 557 tempitem.misc4 = 0;
8095 557 tempitem.misc5 = 0;
8096 557 tempitem.misc6 = 0;
8097 557 tempitem.misc7 = 0;
8098 557 tempitem.misc8 = 0;
8099 557 tempitem.misc9 = 0;
8100 557 tempitem.misc10 = 0;
8101 557 tempitem.wpn = 0;
8102 557 tempitem.wpn2 = 0;
8103 557 tempitem.wpn3 = 0;
8104 557 tempitem.wpn4 = 0;
8105 557 tempitem.wpn5 = 0;
8106 557 tempitem.wpn6 = 0;
8107 557 tempitem.wpn7 = 0;
8108 557 tempitem.wpn8 = 0;
8109 557 tempitem.wpn9 = 0;
8110 557 tempitem.wpn10 = 0;
8111 557 break;
8112 }
8113 case itype_shield:
8114 {
8115 858 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8116 858 tempitem.misc3 = 0;
8117 858 tempitem.misc4 = 0;
8118 858 tempitem.misc5 = 0;
8119 858 tempitem.misc6 = 0;
8120 858 tempitem.misc7 = 0;
8121 858 tempitem.misc8 = 0;
8122 858 tempitem.misc9 = 0;
8123 858 tempitem.misc10 = 0;
8124 858 tempitem.wpn = 0;
8125 858 tempitem.wpn2 = 0;
8126 858 tempitem.wpn3 = 0;
8127 858 tempitem.wpn4 = 0;
8128 858 tempitem.wpn5 = 0;
8129 858 tempitem.wpn6 = 0;
8130 858 tempitem.wpn7 = 0;
8131 858 tempitem.wpn8 = 0;
8132 858 tempitem.wpn9 = 0;
8133 858 tempitem.wpn10 = 0;
8134 858 break;
8135 }
8136 case itype_bow:
8137 {
8138 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8139 558 tempitem.misc1 = 0;
8140 558 tempitem.misc2 = 0;
8141 558 tempitem.misc3 = 0;
8142 558 tempitem.misc4 = 0;
8143 558 tempitem.misc5 = 0;
8144 558 tempitem.misc6 = 0;
8145 558 tempitem.misc7 = 0;
8146 558 tempitem.misc8 = 0;
8147 558 tempitem.misc9 = 0;
8148 558 tempitem.misc10 = 0;
8149 558 tempitem.wpn = 0;
8150 558 tempitem.wpn2 = 0;
8151 558 tempitem.wpn3 = 0;
8152 558 tempitem.wpn4 = 0;
8153 558 tempitem.wpn5 = 0;
8154 558 tempitem.wpn6 = 0;
8155 558 tempitem.wpn7 = 0;
8156 558 tempitem.wpn8 = 0;
8157 558 tempitem.wpn9 = 0;
8158 558 tempitem.wpn10 = 0;
8159 558 break;
8160 }
8161 case itype_raft:
8162 {
8163 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8164 279 tempitem.misc1 = 0;
8165 279 tempitem.misc2 = 0;
8166 279 tempitem.misc3 = 0;
8167 279 tempitem.misc4 = 0;
8168 279 tempitem.misc5 = 0;
8169 279 tempitem.misc6 = 0;
8170 279 tempitem.misc7 = 0;
8171 279 tempitem.misc8 = 0;
8172 279 tempitem.misc9 = 0;
8173 279 tempitem.misc10 = 0;
8174 279 tempitem.wpn = 0;
8175 279 tempitem.wpn2 = 0;
8176 279 tempitem.wpn3 = 0;
8177 279 tempitem.wpn4 = 0;
8178 279 tempitem.wpn5 = 0;
8179 279 tempitem.wpn6 = 0;
8180 279 tempitem.wpn7 = 0;
8181 279 tempitem.wpn8 = 0;
8182 279 tempitem.wpn9 = 0;
8183 279 tempitem.wpn10 = 0;
8184 279 break;
8185 }
8186 case itype_ladder:
8187 {
8188 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8189 558 tempitem.misc1 = 0;
8190 558 tempitem.misc2 = 0;
8191 558 tempitem.misc3 = 0;
8192 558 tempitem.misc4 = 0;
8193 558 tempitem.misc5 = 0;
8194 558 tempitem.misc6 = 0;
8195 558 tempitem.misc7 = 0;
8196 558 tempitem.misc8 = 0;
8197 558 tempitem.misc9 = 0;
8198 558 tempitem.misc10 = 0;
8199 558 tempitem.wpn = 0;
8200 558 tempitem.wpn2 = 0;
8201 558 tempitem.wpn3 = 0;
8202 558 tempitem.wpn4 = 0;
8203 558 tempitem.wpn5 = 0;
8204 558 tempitem.wpn6 = 0;
8205 558 tempitem.wpn7 = 0;
8206 558 tempitem.wpn8 = 0;
8207 558 tempitem.wpn9 = 0;
8208 558 tempitem.wpn10 = 0;
8209 558 break;
8210 }
8211 case itype_book:
8212 {
8213 295 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8214 295 tempitem.misc1 = 0;
8215 295 tempitem.misc2 = 0;
8216 295 tempitem.misc3 = 0;
8217 295 tempitem.misc4 = 0;
8218 295 tempitem.misc5 = 0;
8219 295 tempitem.misc6 = 0;
8220 295 tempitem.misc7 = 0;
8221 295 tempitem.misc8 = 0;
8222 295 tempitem.misc9 = 0;
8223 295 tempitem.misc10 = 0;
8224 295 tempitem.wpn3 = 0;
8225 295 tempitem.wpn4 = 0;
8226 295 tempitem.wpn5 = 0;
8227 295 tempitem.wpn6 = 0;
8228 295 tempitem.wpn7 = 0;
8229 295 tempitem.wpn8 = 0;
8230 295 tempitem.wpn9 = 0;
8231 295 tempitem.wpn10 = 0;
8232 295 break;
8233 }
8234 case itype_magickey:
8235 {
8236 279 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8237 279 tempitem.misc1 = 0;
8238 279 tempitem.misc2 = 0;
8239 279 tempitem.misc3 = 0;
8240 279 tempitem.misc4 = 0;
8241 279 tempitem.misc5 = 0;
8242 279 tempitem.misc6 = 0;
8243 279 tempitem.misc7 = 0;
8244 279 tempitem.misc8 = 0;
8245 279 tempitem.misc9 = 0;
8246 279 tempitem.misc10 = 0;
8247 279 tempitem.wpn = 0;
8248 279 tempitem.wpn2 = 0;
8249 279 tempitem.wpn3 = 0;
8250 279 tempitem.wpn4 = 0;
8251 279 tempitem.wpn5 = 0;
8252 279 tempitem.wpn6 = 0;
8253 279 tempitem.wpn7 = 0;
8254 279 tempitem.wpn8 = 0;
8255 279 tempitem.wpn9 = 0;
8256 279 tempitem.wpn10 = 0;
8257 279 break;
8258 }
8259 case itype_bracelet:
8260 {
8261 846 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8262 846 tempitem.misc1 = 0;
8263 846 tempitem.misc2 = 0;
8264 846 tempitem.misc3 = 0;
8265 846 tempitem.misc4 = 0;
8266 846 tempitem.misc5 = 0;
8267 846 tempitem.misc6 = 0;
8268 846 tempitem.misc7 = 0;
8269 846 tempitem.misc8 = 0;
8270 846 tempitem.misc9 = 0;
8271 846 tempitem.misc10 = 0;
8272 846 tempitem.wpn = 0;
8273 846 tempitem.wpn2 = 0;
8274 846 tempitem.wpn3 = 0;
8275 846 tempitem.wpn4 = 0;
8276 846 tempitem.wpn5 = 0;
8277 846 tempitem.wpn6 = 0;
8278 846 tempitem.wpn7 = 0;
8279 846 tempitem.wpn8 = 0;
8280 846 tempitem.wpn9 = 0;
8281 846 tempitem.wpn10 = 0;
8282 846 break;
8283 }
8284 case itype_flippers:
8285 {
8286 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8287 282 tempitem.misc1 = 0;
8288 282 tempitem.misc2 = 0;
8289 282 tempitem.misc3 = 0;
8290 282 tempitem.misc4 = 0;
8291 282 tempitem.misc5 = 0;
8292 282 tempitem.misc6 = 0;
8293 282 tempitem.misc7 = 0;
8294 282 tempitem.misc8 = 0;
8295 282 tempitem.misc9 = 0;
8296 282 tempitem.misc10 = 0;
8297 282 tempitem.wpn = 0;
8298 282 tempitem.wpn2 = 0;
8299 282 tempitem.wpn3 = 0;
8300 282 tempitem.wpn4 = 0;
8301 282 tempitem.wpn5 = 0;
8302 282 tempitem.wpn6 = 0;
8303 282 tempitem.wpn7 = 0;
8304 282 tempitem.wpn8 = 0;
8305 282 tempitem.wpn9 = 0;
8306 282 tempitem.wpn10 = 0;
8307 282 break;
8308 }
8309 case itype_boots:
8310 {
8311 285 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8312 285 tempitem.misc1 = 0;
8313 285 tempitem.misc2 = 0;
8314 285 tempitem.misc3 = 0;
8315 285 tempitem.misc4 = 0;
8316 285 tempitem.misc5 = 0;
8317 285 tempitem.misc6 = 0;
8318 285 tempitem.misc7 = 0;
8319 285 tempitem.misc8 = 0;
8320 285 tempitem.misc9 = 0;
8321 285 tempitem.misc10 = 0;
8322 285 tempitem.wpn = 0;
8323 285 tempitem.wpn2 = 0;
8324 285 tempitem.wpn3 = 0;
8325 285 tempitem.wpn4 = 0;
8326 285 tempitem.wpn5 = 0;
8327 285 tempitem.wpn6 = 0;
8328 285 tempitem.wpn7 = 0;
8329 285 tempitem.wpn8 = 0;
8330 285 tempitem.wpn9 = 0;
8331 285 tempitem.wpn10 = 0;
8332 285 break;
8333 }
8334 case itype_hookshot:
8335 {
8336 560 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8337 560 tempitem.misc5 = 0;
8338 560 tempitem.misc6 = 0;
8339 560 tempitem.misc7 = 0;
8340 560 tempitem.misc8 = 0;
8341 560 tempitem.misc9 = 0;
8342 560 tempitem.misc10 = 0;
8343 560 tempitem.wpn5 = 0;
8344 560 tempitem.wpn6 = 0;
8345 560 tempitem.wpn7 = 0;
8346 560 tempitem.wpn8 = 0;
8347 560 tempitem.wpn9 = 0;
8348 560 tempitem.wpn10 = 0;
8349 560 break;
8350 }
8351 case itype_lens:
8352 {
8353 255 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8354 255 tempitem.misc2 = 0;
8355 255 tempitem.misc3 = 0;
8356 255 tempitem.misc4 = 0;
8357 255 tempitem.misc5 = 0;
8358 255 tempitem.misc6 = 0;
8359 255 tempitem.misc7 = 0;
8360 255 tempitem.misc8 = 0;
8361 255 tempitem.misc9 = 0;
8362 255 tempitem.misc10 = 0;
8363 255 tempitem.wpn = 0;
8364 255 tempitem.wpn2 = 0;
8365 255 tempitem.wpn3 = 0;
8366 255 tempitem.wpn4 = 0;
8367 255 tempitem.wpn5 = 0;
8368 255 tempitem.wpn6 = 0;
8369 255 tempitem.wpn7 = 0;
8370 255 tempitem.wpn8 = 0;
8371 255 tempitem.wpn9 = 0;
8372 255 tempitem.wpn10 = 0;
8373 255 break;
8374 }
8375 case itype_hammer:
8376 {
8377 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8378 282 tempitem.misc1 = 0;
8379 282 tempitem.misc2 = 0;
8380 282 tempitem.misc3 = 0;
8381 282 tempitem.misc4 = 0;
8382 282 tempitem.misc5 = 0;
8383 282 tempitem.misc6 = 0;
8384 282 tempitem.misc7 = 0;
8385 282 tempitem.misc8 = 0;
8386 282 tempitem.misc9 = 0;
8387 282 tempitem.misc10 = 0;
8388 282 tempitem.wpn3 = 0;
8389 282 tempitem.wpn4 = 0;
8390 282 tempitem.wpn5 = 0;
8391 282 tempitem.wpn6 = 0;
8392 282 tempitem.wpn7 = 0;
8393 282 tempitem.wpn8 = 0;
8394 282 tempitem.wpn9 = 0;
8395 282 tempitem.wpn10 = 0;
8396 282 break;
8397 }
8398 case itype_divinefire:
8399 {
8400 279 tempitem.flags &= ~ (item_flag1 | item_flag4 | item_flag5);
8401 279 tempitem.misc3 = 0;
8402 279 tempitem.misc4 = 0;
8403 279 tempitem.misc5 = 0;
8404 279 tempitem.misc6 = 0;
8405 279 tempitem.misc7 = 0;
8406 279 tempitem.misc8 = 0;
8407 279 tempitem.misc9 = 0;
8408 279 tempitem.misc10 = 0;
8409 279 tempitem.wpn6 = 0;
8410 279 tempitem.wpn7 = 0;
8411 279 tempitem.wpn8 = 0;
8412 279 tempitem.wpn9 = 0;
8413 279 tempitem.wpn10 = 0;
8414 279 break;
8415 }
8416 case itype_divineescape:
8417 {
8418 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8419 279 tempitem.misc2 = 0;
8420 279 tempitem.misc3 = 0;
8421 279 tempitem.misc4 = 0;
8422 279 tempitem.misc5 = 0;
8423 279 tempitem.misc6 = 0;
8424 279 tempitem.misc7 = 0;
8425 279 tempitem.misc8 = 0;
8426 279 tempitem.misc9 = 0;
8427 279 tempitem.misc10 = 0;
8428 279 tempitem.wpn = 0;
8429 279 tempitem.wpn2 = 0;
8430 279 tempitem.wpn3 = 0;
8431 279 tempitem.wpn4 = 0;
8432 279 tempitem.wpn5 = 0;
8433 279 tempitem.wpn6 = 0;
8434 279 tempitem.wpn7 = 0;
8435 279 tempitem.wpn8 = 0;
8436 279 tempitem.wpn9 = 0;
8437 279 tempitem.wpn10 = 0;
8438 279 break;
8439 }
8440 case itype_divineprotection:
8441 {
8442 279 tempitem.flags &= ~ (item_flag5);
8443 279 tempitem.misc2 = 0;
8444 279 tempitem.misc3 = 0;
8445 279 tempitem.misc4 = 0;
8446 279 tempitem.misc5 = 0;
8447 279 tempitem.misc6 = 0;
8448 279 tempitem.misc7 = 0;
8449 279 tempitem.misc8 = 0;
8450 279 tempitem.misc9 = 0;
8451 279 tempitem.misc10 = 0;
8452 279 break;
8453 }
8454 case itype_bomb:
8455 {
8456 295 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8457 295 tempitem.misc4 = 0;
8458 295 tempitem.misc5 = 0;
8459 295 tempitem.misc6 = 0;
8460 295 tempitem.misc7 = 0;
8461 295 tempitem.misc8 = 0;
8462 295 tempitem.misc9 = 0;
8463 295 tempitem.misc10 = 0;
8464 295 tempitem.wpn3 = 0;
8465 295 tempitem.wpn4 = 0;
8466 295 tempitem.wpn5 = 0;
8467 295 tempitem.wpn6 = 0;
8468 295 tempitem.wpn7 = 0;
8469 295 tempitem.wpn8 = 0;
8470 295 tempitem.wpn9 = 0;
8471 295 tempitem.wpn10 = 0;
8472 295 break;
8473 }
8474 case itype_sbomb:
8475 {
8476 281 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8477 281 tempitem.misc4 = 0;
8478 281 tempitem.misc5 = 0;
8479 281 tempitem.misc6 = 0;
8480 281 tempitem.misc7 = 0;
8481 281 tempitem.misc8 = 0;
8482 281 tempitem.misc9 = 0;
8483 281 tempitem.misc10 = 0;
8484 281 tempitem.wpn3 = 0;
8485 281 tempitem.wpn4 = 0;
8486 281 tempitem.wpn5 = 0;
8487 281 tempitem.wpn6 = 0;
8488 281 tempitem.wpn7 = 0;
8489 281 tempitem.wpn8 = 0;
8490 281 tempitem.wpn9 = 0;
8491 281 tempitem.wpn10 = 0;
8492 281 break;
8493 }
8494 case itype_clock:
8495 {
8496 282 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8497 282 tempitem.misc2 = 0;
8498 282 tempitem.misc3 = 0;
8499 282 tempitem.misc4 = 0;
8500 282 tempitem.misc5 = 0;
8501 282 tempitem.misc6 = 0;
8502 282 tempitem.misc7 = 0;
8503 282 tempitem.misc8 = 0;
8504 282 tempitem.misc9 = 0;
8505 282 tempitem.misc10 = 0;
8506 282 tempitem.wpn = 0;
8507 282 tempitem.wpn2 = 0;
8508 282 tempitem.wpn3 = 0;
8509 282 tempitem.wpn4 = 0;
8510 282 tempitem.wpn5 = 0;
8511 282 tempitem.wpn6 = 0;
8512 282 tempitem.wpn7 = 0;
8513 282 tempitem.wpn8 = 0;
8514 282 tempitem.wpn9 = 0;
8515 282 tempitem.wpn10 = 0;
8516 282 break;
8517 }
8518 case itype_key:
8519 {
8520 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8521 279 tempitem.misc1 = 0;
8522 279 tempitem.misc2 = 0;
8523 279 tempitem.misc3 = 0;
8524 279 tempitem.misc4 = 0;
8525 279 tempitem.misc5 = 0;
8526 279 tempitem.misc6 = 0;
8527 279 tempitem.misc7 = 0;
8528 279 tempitem.misc8 = 0;
8529 279 tempitem.misc9 = 0;
8530 279 tempitem.misc10 = 0;
8531 279 tempitem.wpn = 0;
8532 279 tempitem.wpn2 = 0;
8533 279 tempitem.wpn3 = 0;
8534 279 tempitem.wpn4 = 0;
8535 279 tempitem.wpn5 = 0;
8536 279 tempitem.wpn6 = 0;
8537 279 tempitem.wpn7 = 0;
8538 279 tempitem.wpn8 = 0;
8539 279 tempitem.wpn9 = 0;
8540 279 tempitem.wpn10 = 0;
8541 279 break;
8542 }
8543 case itype_magiccontainer:
8544 {
8545 284 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8546 284 tempitem.misc1 = 0;
8547 284 tempitem.misc2 = 0;
8548 284 tempitem.misc3 = 0;
8549 284 tempitem.misc4 = 0;
8550 284 tempitem.misc5 = 0;
8551 284 tempitem.misc6 = 0;
8552 284 tempitem.misc7 = 0;
8553 284 tempitem.misc8 = 0;
8554 284 tempitem.misc9 = 0;
8555 284 tempitem.misc10 = 0;
8556 284 tempitem.wpn = 0;
8557 284 tempitem.wpn2 = 0;
8558 284 tempitem.wpn3 = 0;
8559 284 tempitem.wpn4 = 0;
8560 284 tempitem.wpn5 = 0;
8561 284 tempitem.wpn6 = 0;
8562 284 tempitem.wpn7 = 0;
8563 284 tempitem.wpn8 = 0;
8564 284 tempitem.wpn9 = 0;
8565 284 tempitem.wpn10 = 0;
8566 284 break;
8567 }
8568 case itype_triforcepiece:
8569 {
8570 558 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8571 558 tempitem.misc3 = 0;
8572 558 tempitem.misc4 = 0;
8573 558 tempitem.misc5 = 0;
8574 558 tempitem.misc6 = 0;
8575 558 tempitem.misc7 = 0;
8576 558 tempitem.misc8 = 0;
8577 558 tempitem.misc9 = 0;
8578 558 tempitem.misc10 = 0;
8579 558 tempitem.wpn = 0;
8580 558 tempitem.wpn2 = 0;
8581 558 tempitem.wpn3 = 0;
8582 558 tempitem.wpn4 = 0;
8583 558 tempitem.wpn5 = 0;
8584 558 tempitem.wpn6 = 0;
8585 558 tempitem.wpn7 = 0;
8586 558 tempitem.wpn8 = 0;
8587 558 tempitem.wpn9 = 0;
8588 558 tempitem.wpn10 = 0;
8589 558 break;
8590 }
8591 case itype_map: case itype_compass: case itype_bosskey:
8592 {
8593 842 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8594 842 tempitem.misc1 = 0;
8595 842 tempitem.misc2 = 0;
8596 842 tempitem.misc3 = 0;
8597 842 tempitem.misc4 = 0;
8598 842 tempitem.misc5 = 0;
8599 842 tempitem.misc6 = 0;
8600 842 tempitem.misc7 = 0;
8601 842 tempitem.misc8 = 0;
8602 842 tempitem.misc9 = 0;
8603 842 tempitem.misc10 = 0;
8604 842 tempitem.wpn = 0;
8605 842 tempitem.wpn2 = 0;
8606 842 tempitem.wpn3 = 0;
8607 842 tempitem.wpn4 = 0;
8608 842 tempitem.wpn5 = 0;
8609 842 tempitem.wpn6 = 0;
8610 842 tempitem.wpn7 = 0;
8611 842 tempitem.wpn8 = 0;
8612 842 tempitem.wpn9 = 0;
8613 842 tempitem.wpn10 = 0;
8614 842 break;
8615 }
8616 case itype_quiver:
8617 {
8618 1116 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8619 1116 tempitem.misc3 = 0;
8620 1116 tempitem.misc4 = 0;
8621 1116 tempitem.misc5 = 0;
8622 1116 tempitem.misc6 = 0;
8623 1116 tempitem.misc7 = 0;
8624 1116 tempitem.misc8 = 0;
8625 1116 tempitem.misc9 = 0;
8626 1116 tempitem.misc10 = 0;
8627 1116 tempitem.wpn = 0;
8628 1116 tempitem.wpn2 = 0;
8629 1116 tempitem.wpn3 = 0;
8630 1116 tempitem.wpn4 = 0;
8631 1116 tempitem.wpn5 = 0;
8632 1116 tempitem.wpn6 = 0;
8633 1116 tempitem.wpn7 = 0;
8634 1116 tempitem.wpn8 = 0;
8635 1116 tempitem.wpn9 = 0;
8636 1116 tempitem.wpn10 = 0;
8637 1116 break;
8638 }
8639 case itype_lkey:
8640 {
8641 780 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8642 780 tempitem.misc1 = 0;
8643 780 tempitem.misc2 = 0;
8644 780 tempitem.misc3 = 0;
8645 780 tempitem.misc4 = 0;
8646 780 tempitem.misc5 = 0;
8647 780 tempitem.misc6 = 0;
8648 780 tempitem.misc7 = 0;
8649 780 tempitem.misc8 = 0;
8650 780 tempitem.misc9 = 0;
8651 780 tempitem.misc10 = 0;
8652 780 tempitem.wpn = 0;
8653 780 tempitem.wpn2 = 0;
8654 780 tempitem.wpn3 = 0;
8655 780 tempitem.wpn4 = 0;
8656 780 tempitem.wpn5 = 0;
8657 780 tempitem.wpn6 = 0;
8658 780 tempitem.wpn7 = 0;
8659 780 tempitem.wpn8 = 0;
8660 780 tempitem.wpn9 = 0;
8661 780 tempitem.wpn10 = 0;
8662 780 break;
8663 }
8664 case itype_cbyrna:
8665 {
8666 279 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
8667 279 tempitem.misc4 = 0;
8668 279 tempitem.misc5 = 0;
8669 279 tempitem.misc6 = 0;
8670 279 tempitem.misc7 = 0;
8671 279 tempitem.misc8 = 0;
8672 279 tempitem.misc9 = 0;
8673 279 tempitem.misc10 = 0;
8674 279 tempitem.wpn6 = 0;
8675 279 tempitem.wpn7 = 0;
8676 279 tempitem.wpn8 = 0;
8677 279 tempitem.wpn9 = 0;
8678 279 tempitem.wpn10 = 0;
8679 279 break;
8680 }
8681 case itype_rupee: case itype_arrowammo:
8682 {
8683 3261 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8684 3261 tempitem.misc1 = 0;
8685 3261 tempitem.misc2 = 0;
8686 3261 tempitem.misc3 = 0;
8687 3261 tempitem.misc4 = 0;
8688 3261 tempitem.misc5 = 0;
8689 3261 tempitem.misc6 = 0;
8690 3261 tempitem.misc7 = 0;
8691 3261 tempitem.misc8 = 0;
8692 3261 tempitem.misc9 = 0;
8693 3261 tempitem.misc10 = 0;
8694 3261 tempitem.wpn = 0;
8695 3261 tempitem.wpn2 = 0;
8696 3261 tempitem.wpn3 = 0;
8697 3261 tempitem.wpn4 = 0;
8698 3261 tempitem.wpn5 = 0;
8699 3261 tempitem.wpn6 = 0;
8700 3261 tempitem.wpn7 = 0;
8701 3261 tempitem.wpn8 = 0;
8702 3261 tempitem.wpn9 = 0;
8703 3261 tempitem.wpn10 = 0;
8704 3261 break;
8705 }
8706 case itype_fairy:
8707 {
8708 545 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
8709 545 tempitem.misc4 = 0;
8710 545 tempitem.misc5 = 0;
8711 545 tempitem.misc6 = 0;
8712 545 tempitem.misc7 = 0;
8713 545 tempitem.misc8 = 0;
8714 545 tempitem.misc9 = 0;
8715 545 tempitem.misc10 = 0;
8716 545 tempitem.wpn = 0;
8717 545 tempitem.wpn2 = 0;
8718 545 tempitem.wpn3 = 0;
8719 545 tempitem.wpn4 = 0;
8720 545 tempitem.wpn5 = 0;
8721 545 tempitem.wpn6 = 0;
8722 545 tempitem.wpn7 = 0;
8723 545 tempitem.wpn8 = 0;
8724 545 tempitem.wpn9 = 0;
8725 545 tempitem.wpn10 = 0;
8726 545 break;
8727 }
8728 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8729 {
8730 2872 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8731 2872 tempitem.misc1 = 0;
8732 2872 tempitem.misc2 = 0;
8733 2872 tempitem.misc3 = 0;
8734 2872 tempitem.misc4 = 0;
8735 2872 tempitem.misc5 = 0;
8736 2872 tempitem.misc6 = 0;
8737 2872 tempitem.misc7 = 0;
8738 2872 tempitem.misc8 = 0;
8739 2872 tempitem.misc9 = 0;
8740 2872 tempitem.misc10 = 0;
8741 2872 tempitem.wpn = 0;
8742 2872 tempitem.wpn2 = 0;
8743 2872 tempitem.wpn3 = 0;
8744 2872 tempitem.wpn4 = 0;
8745 2872 tempitem.wpn5 = 0;
8746 2872 tempitem.wpn6 = 0;
8747 2872 tempitem.wpn7 = 0;
8748 2872 tempitem.wpn8 = 0;
8749 2872 tempitem.wpn9 = 0;
8750 2872 tempitem.wpn10 = 0;
8751 2872 break;
8752 }
8753 case itype_bombbag:
8754 {
8755 1116 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8756 1116 tempitem.misc3 = 0;
8757 1116 tempitem.misc4 = 0;
8758 1116 tempitem.misc5 = 0;
8759 1116 tempitem.misc6 = 0;
8760 1116 tempitem.misc7 = 0;
8761 1116 tempitem.misc8 = 0;
8762 1116 tempitem.misc9 = 0;
8763 1116 tempitem.misc10 = 0;
8764 1116 tempitem.wpn = 0;
8765 1116 tempitem.wpn2 = 0;
8766 1116 tempitem.wpn3 = 0;
8767 1116 tempitem.wpn4 = 0;
8768 1116 tempitem.wpn5 = 0;
8769 1116 tempitem.wpn6 = 0;
8770 1116 tempitem.wpn7 = 0;
8771 1116 tempitem.wpn8 = 0;
8772 1116 tempitem.wpn9 = 0;
8773 1116 tempitem.wpn10 = 0;
8774 1116 break;
8775 }
8776 case itype_rocs:
8777 {
8778 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8779 279 tempitem.misc1 = 0;
8780 279 tempitem.misc2 = 0;
8781 279 tempitem.misc3 = 0;
8782 279 tempitem.misc4 = 0;
8783 279 tempitem.misc5 = 0;
8784 279 tempitem.misc6 = 0;
8785 279 tempitem.misc7 = 0;
8786 279 tempitem.misc8 = 0;
8787 279 tempitem.misc9 = 0;
8788 279 tempitem.misc10 = 0;
8789 279 tempitem.wpn = 0;
8790 279 tempitem.wpn2 = 0;
8791 279 tempitem.wpn3 = 0;
8792 279 tempitem.wpn4 = 0;
8793 279 tempitem.wpn5 = 0;
8794 279 tempitem.wpn6 = 0;
8795 279 tempitem.wpn7 = 0;
8796 279 tempitem.wpn8 = 0;
8797 279 tempitem.wpn9 = 0;
8798 279 tempitem.wpn10 = 0;
8799 279 break;
8800 }
8801 case itype_hoverboots:
8802 {
8803 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8804 279 tempitem.misc2 = 0;
8805 279 tempitem.misc3 = 0;
8806 279 tempitem.misc4 = 0;
8807 279 tempitem.misc5 = 0;
8808 279 tempitem.misc6 = 0;
8809 279 tempitem.misc7 = 0;
8810 279 tempitem.misc8 = 0;
8811 279 tempitem.misc9 = 0;
8812 279 tempitem.misc10 = 0;
8813 279 tempitem.wpn2 = 0;
8814 279 tempitem.wpn3 = 0;
8815 279 tempitem.wpn4 = 0;
8816 279 tempitem.wpn5 = 0;
8817 279 tempitem.wpn6 = 0;
8818 279 tempitem.wpn7 = 0;
8819 279 tempitem.wpn8 = 0;
8820 279 tempitem.wpn9 = 0;
8821 279 tempitem.wpn10 = 0;
8822 279 break;
8823 }
8824 case itype_spinscroll:
8825 {
8826 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8827 279 tempitem.misc2 = 0;
8828 279 tempitem.misc3 = 0;
8829 279 tempitem.misc4 = 0;
8830 279 tempitem.misc5 = 0;
8831 279 tempitem.misc6 = 0;
8832 279 tempitem.misc7 = 0;
8833 279 tempitem.misc8 = 0;
8834 279 tempitem.misc9 = 0;
8835 279 tempitem.misc10 = 0;
8836 279 tempitem.wpn = 0;
8837 279 tempitem.wpn2 = 0;
8838 279 tempitem.wpn3 = 0;
8839 279 tempitem.wpn4 = 0;
8840 279 tempitem.wpn5 = 0;
8841 279 tempitem.wpn6 = 0;
8842 279 tempitem.wpn7 = 0;
8843 279 tempitem.wpn8 = 0;
8844 279 tempitem.wpn9 = 0;
8845 279 tempitem.wpn10 = 0;
8846 279 break;
8847 }
8848 case itype_crossscroll:
8849 {
8850 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8851 279 tempitem.misc1 = 0;
8852 279 tempitem.misc2 = 0;
8853 279 tempitem.misc3 = 0;
8854 279 tempitem.misc4 = 0;
8855 279 tempitem.misc5 = 0;
8856 279 tempitem.misc6 = 0;
8857 279 tempitem.misc7 = 0;
8858 279 tempitem.misc8 = 0;
8859 279 tempitem.misc9 = 0;
8860 279 tempitem.misc10 = 0;
8861 279 tempitem.wpn = 0;
8862 279 tempitem.wpn2 = 0;
8863 279 tempitem.wpn3 = 0;
8864 279 tempitem.wpn4 = 0;
8865 279 tempitem.wpn5 = 0;
8866 279 tempitem.wpn6 = 0;
8867 279 tempitem.wpn7 = 0;
8868 279 tempitem.wpn8 = 0;
8869 279 tempitem.wpn9 = 0;
8870 279 tempitem.wpn10 = 0;
8871 279 break;
8872 }
8873 case itype_quakescroll:
8874 {
8875 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8876 279 tempitem.misc3 = 0;
8877 279 tempitem.misc4 = 0;
8878 279 tempitem.misc5 = 0;
8879 279 tempitem.misc6 = 0;
8880 279 tempitem.misc7 = 0;
8881 279 tempitem.misc8 = 0;
8882 279 tempitem.misc9 = 0;
8883 279 tempitem.misc10 = 0;
8884 279 tempitem.wpn = 0;
8885 279 tempitem.wpn2 = 0;
8886 279 tempitem.wpn3 = 0;
8887 279 tempitem.wpn4 = 0;
8888 279 tempitem.wpn5 = 0;
8889 279 tempitem.wpn6 = 0;
8890 279 tempitem.wpn7 = 0;
8891 279 tempitem.wpn8 = 0;
8892 279 tempitem.wpn9 = 0;
8893 279 tempitem.wpn10 = 0;
8894 279 break;
8895 }
8896 case itype_whispring:
8897 {
8898 561 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8899 561 tempitem.misc2 = 0;
8900 561 tempitem.misc3 = 0;
8901 561 tempitem.misc4 = 0;
8902 561 tempitem.misc5 = 0;
8903 561 tempitem.misc6 = 0;
8904 561 tempitem.misc7 = 0;
8905 561 tempitem.misc8 = 0;
8906 561 tempitem.misc9 = 0;
8907 561 tempitem.misc10 = 0;
8908 561 tempitem.wpn = 0;
8909 561 tempitem.wpn2 = 0;
8910 561 tempitem.wpn3 = 0;
8911 561 tempitem.wpn4 = 0;
8912 561 tempitem.wpn5 = 0;
8913 561 tempitem.wpn6 = 0;
8914 561 tempitem.wpn7 = 0;
8915 561 tempitem.wpn8 = 0;
8916 561 tempitem.wpn9 = 0;
8917 561 tempitem.wpn10 = 0;
8918 561 break;
8919 }
8920 case itype_chargering:
8921 {
8922 558 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8923 558 tempitem.misc3 = 0;
8924 558 tempitem.misc4 = 0;
8925 558 tempitem.misc5 = 0;
8926 558 tempitem.misc6 = 0;
8927 558 tempitem.misc7 = 0;
8928 558 tempitem.misc8 = 0;
8929 558 tempitem.misc9 = 0;
8930 558 tempitem.misc10 = 0;
8931 558 tempitem.wpn = 0;
8932 558 tempitem.wpn2 = 0;
8933 558 tempitem.wpn3 = 0;
8934 558 tempitem.wpn4 = 0;
8935 558 tempitem.wpn5 = 0;
8936 558 tempitem.wpn6 = 0;
8937 558 tempitem.wpn7 = 0;
8938 558 tempitem.wpn8 = 0;
8939 558 tempitem.wpn9 = 0;
8940 558 tempitem.wpn10 = 0;
8941 558 break;
8942 }
8943 case itype_perilscroll:
8944 {
8945 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8946 279 tempitem.misc2 = 0;
8947 279 tempitem.misc3 = 0;
8948 279 tempitem.misc4 = 0;
8949 279 tempitem.misc5 = 0;
8950 279 tempitem.misc6 = 0;
8951 279 tempitem.misc7 = 0;
8952 279 tempitem.misc8 = 0;
8953 279 tempitem.misc9 = 0;
8954 279 tempitem.misc10 = 0;
8955 279 tempitem.wpn = 0;
8956 279 tempitem.wpn2 = 0;
8957 279 tempitem.wpn3 = 0;
8958 279 tempitem.wpn4 = 0;
8959 279 tempitem.wpn5 = 0;
8960 279 tempitem.wpn6 = 0;
8961 279 tempitem.wpn7 = 0;
8962 279 tempitem.wpn8 = 0;
8963 279 tempitem.wpn9 = 0;
8964 279 tempitem.wpn10 = 0;
8965 279 break;
8966 }
8967 case itype_wealthmedal:
8968 {
8969 840 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8970 840 tempitem.misc2 = 0;
8971 840 tempitem.misc3 = 0;
8972 840 tempitem.misc4 = 0;
8973 840 tempitem.misc5 = 0;
8974 840 tempitem.misc6 = 0;
8975 840 tempitem.misc7 = 0;
8976 840 tempitem.misc8 = 0;
8977 840 tempitem.misc9 = 0;
8978 840 tempitem.misc10 = 0;
8979 840 tempitem.wpn = 0;
8980 840 tempitem.wpn2 = 0;
8981 840 tempitem.wpn3 = 0;
8982 840 tempitem.wpn4 = 0;
8983 840 tempitem.wpn5 = 0;
8984 840 tempitem.wpn6 = 0;
8985 840 tempitem.wpn7 = 0;
8986 840 tempitem.wpn8 = 0;
8987 840 tempitem.wpn9 = 0;
8988 840 tempitem.wpn10 = 0;
8989 840 break;
8990 }
8991 case itype_heartring:
8992 {
8993 843 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8994 843 tempitem.misc3 = 0;
8995 843 tempitem.misc4 = 0;
8996 843 tempitem.misc5 = 0;
8997 843 tempitem.misc6 = 0;
8998 843 tempitem.misc7 = 0;
8999 843 tempitem.misc8 = 0;
9000 843 tempitem.misc9 = 0;
9001 843 tempitem.misc10 = 0;
9002 843 tempitem.wpn = 0;
9003 843 tempitem.wpn2 = 0;
9004 843 tempitem.wpn3 = 0;
9005 843 tempitem.wpn4 = 0;
9006 843 tempitem.wpn5 = 0;
9007 843 tempitem.wpn6 = 0;
9008 843 tempitem.wpn7 = 0;
9009 843 tempitem.wpn8 = 0;
9010 843 tempitem.wpn9 = 0;
9011 843 tempitem.wpn10 = 0;
9012 843 break;
9013 }
9014 case itype_magicring:
9015 {
9016 1128 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9017 1128 tempitem.misc3 = 0;
9018 1128 tempitem.misc4 = 0;
9019 1128 tempitem.misc5 = 0;
9020 1128 tempitem.misc6 = 0;
9021 1128 tempitem.misc7 = 0;
9022 1128 tempitem.misc8 = 0;
9023 1128 tempitem.misc9 = 0;
9024 1128 tempitem.misc10 = 0;
9025 1128 tempitem.wpn = 0;
9026 1128 tempitem.wpn2 = 0;
9027 1128 tempitem.wpn3 = 0;
9028 1128 tempitem.wpn4 = 0;
9029 1128 tempitem.wpn5 = 0;
9030 1128 tempitem.wpn6 = 0;
9031 1128 tempitem.wpn7 = 0;
9032 1128 tempitem.wpn8 = 0;
9033 1128 tempitem.wpn9 = 0;
9034 1128 tempitem.wpn10 = 0;
9035 1128 break;
9036 }
9037 case itype_spinscroll2:
9038 {
9039 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9040 279 tempitem.misc2 = 0;
9041 279 tempitem.misc3 = 0;
9042 279 tempitem.misc4 = 0;
9043 279 tempitem.misc5 = 0;
9044 279 tempitem.misc6 = 0;
9045 279 tempitem.misc7 = 0;
9046 279 tempitem.misc8 = 0;
9047 279 tempitem.misc9 = 0;
9048 279 tempitem.misc10 = 0;
9049 279 tempitem.wpn = 0;
9050 279 tempitem.wpn2 = 0;
9051 279 tempitem.wpn3 = 0;
9052 279 tempitem.wpn4 = 0;
9053 279 tempitem.wpn5 = 0;
9054 279 tempitem.wpn6 = 0;
9055 279 tempitem.wpn7 = 0;
9056 279 tempitem.wpn8 = 0;
9057 279 tempitem.wpn9 = 0;
9058 279 tempitem.wpn10 = 0;
9059 279 break;
9060 }
9061 case itype_quakescroll2:
9062 {
9063 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9064 279 tempitem.misc3 = 0;
9065 279 tempitem.misc4 = 0;
9066 279 tempitem.misc5 = 0;
9067 279 tempitem.misc6 = 0;
9068 279 tempitem.misc7 = 0;
9069 279 tempitem.misc8 = 0;
9070 279 tempitem.misc9 = 0;
9071 279 tempitem.misc10 = 0;
9072 279 tempitem.wpn = 0;
9073 279 tempitem.wpn2 = 0;
9074 279 tempitem.wpn3 = 0;
9075 279 tempitem.wpn4 = 0;
9076 279 tempitem.wpn5 = 0;
9077 279 tempitem.wpn6 = 0;
9078 279 tempitem.wpn7 = 0;
9079 279 tempitem.wpn8 = 0;
9080 279 tempitem.wpn9 = 0;
9081 279 tempitem.wpn10 = 0;
9082 279 break;
9083 }
9084 case itype_agony:
9085 {
9086 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9087 279 tempitem.misc2 = 0;
9088 279 tempitem.misc3 = 0;
9089 279 tempitem.misc4 = 0;
9090 279 tempitem.misc5 = 0;
9091 279 tempitem.misc6 = 0;
9092 279 tempitem.misc7 = 0;
9093 279 tempitem.misc8 = 0;
9094 279 tempitem.misc9 = 0;
9095 279 tempitem.misc10 = 0;
9096 279 tempitem.wpn = 0;
9097 279 tempitem.wpn2 = 0;
9098 279 tempitem.wpn3 = 0;
9099 279 tempitem.wpn4 = 0;
9100 279 tempitem.wpn5 = 0;
9101 279 tempitem.wpn6 = 0;
9102 279 tempitem.wpn7 = 0;
9103 279 tempitem.wpn8 = 0;
9104 279 tempitem.wpn9 = 0;
9105 279 tempitem.wpn10 = 0;
9106 279 break;
9107 }
9108 case itype_stompboots:
9109 {
9110 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9111 279 tempitem.misc1 = 0;
9112 279 tempitem.misc2 = 0;
9113 279 tempitem.misc3 = 0;
9114 279 tempitem.misc4 = 0;
9115 279 tempitem.misc5 = 0;
9116 279 tempitem.misc6 = 0;
9117 279 tempitem.misc7 = 0;
9118 279 tempitem.misc8 = 0;
9119 279 tempitem.misc9 = 0;
9120 279 tempitem.misc10 = 0;
9121 279 tempitem.wpn = 0;
9122 279 tempitem.wpn2 = 0;
9123 279 tempitem.wpn3 = 0;
9124 279 tempitem.wpn4 = 0;
9125 279 tempitem.wpn5 = 0;
9126 279 tempitem.wpn6 = 0;
9127 279 tempitem.wpn7 = 0;
9128 279 tempitem.wpn8 = 0;
9129 279 tempitem.wpn9 = 0;
9130 279 tempitem.wpn10 = 0;
9131 279 break;
9132 }
9133 case itype_whimsicalring:
9134 {
9135 279 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9136 279 tempitem.misc2 = 0;
9137 279 tempitem.misc3 = 0;
9138 279 tempitem.misc4 = 0;
9139 279 tempitem.misc5 = 0;
9140 279 tempitem.misc6 = 0;
9141 279 tempitem.misc7 = 0;
9142 279 tempitem.misc8 = 0;
9143 279 tempitem.misc9 = 0;
9144 279 tempitem.misc10 = 0;
9145 279 tempitem.wpn = 0;
9146 279 tempitem.wpn2 = 0;
9147 279 tempitem.wpn3 = 0;
9148 279 tempitem.wpn4 = 0;
9149 279 tempitem.wpn5 = 0;
9150 279 tempitem.wpn6 = 0;
9151 279 tempitem.wpn7 = 0;
9152 279 tempitem.wpn8 = 0;
9153 279 tempitem.wpn9 = 0;
9154 279 tempitem.wpn10 = 0;
9155 279 break;
9156 }
9157 case itype_perilring:
9158 {
9159 306 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9160 306 tempitem.misc2 = 0;
9161 306 tempitem.misc3 = 0;
9162 306 tempitem.misc4 = 0;
9163 306 tempitem.misc5 = 0;
9164 306 tempitem.misc6 = 0;
9165 306 tempitem.misc7 = 0;
9166 306 tempitem.misc8 = 0;
9167 306 tempitem.misc9 = 0;
9168 306 tempitem.misc10 = 0;
9169 306 tempitem.wpn = 0;
9170 306 tempitem.wpn2 = 0;
9171 306 tempitem.wpn3 = 0;
9172 306 tempitem.wpn4 = 0;
9173 306 tempitem.wpn5 = 0;
9174 306 tempitem.wpn6 = 0;
9175 306 tempitem.wpn7 = 0;
9176 306 tempitem.wpn8 = 0;
9177 306 tempitem.wpn9 = 0;
9178 306 tempitem.wpn10 = 0;
9179 306 break;
9180 }
9181 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9182 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9183 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9184 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9185 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9186 {
9187 10652 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9188 10652 tempitem.misc1 = 0;
9189 10652 tempitem.misc2 = 0;
9190 10652 tempitem.misc3 = 0;
9191 10652 tempitem.misc4 = 0;
9192 10652 tempitem.misc5 = 0;
9193 10652 tempitem.misc6 = 0;
9194 10652 tempitem.misc7 = 0;
9195 10652 tempitem.misc8 = 0;
9196 10652 tempitem.misc9 = 0;
9197 10652 tempitem.misc10 = 0;
9198 10652 tempitem.wpn = 0;
9199 10652 tempitem.wpn2 = 0;
9200 10652 tempitem.wpn3 = 0;
9201 10652 tempitem.wpn4 = 0;
9202 10652 tempitem.wpn5 = 0;
9203 10652 tempitem.wpn6 = 0;
9204 10652 tempitem.wpn7 = 0;
9205 10652 tempitem.wpn8 = 0;
9206 10652 tempitem.wpn9 = 0;
9207 10652 tempitem.wpn10 = 0;
9208 10652 break;
9209 }
9210 }
9211 72192 }
9212 //Port quest rules to items
9213
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 72192 times.
125440 if( s_version <= 31)
9214 {
9215
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 71897 times.
72192 if(tempitem.type == itype_bomb)
9216 {
9217
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 139 times.
295 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9218 139 else tempitem.flags &= ~ item_flag2;
9219 295 }
9220
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 71616 times.
71897 else if(tempitem.type == itype_sbomb)
9221 {
9222
2/2
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 123 times.
281 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9223 123 else tempitem.flags &= ~ item_flag2;
9224 281 }
9225
9226
2/2
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 70772 times.
71616 else if(tempitem.type == itype_brang)
9227 {
9228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 844 times.
844 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= item_flag4;
9229 844 else tempitem.flags &= ~ item_flag4;
9230 844 }
9231
2/2
✓ Branch 0 taken 70475 times.
✓ Branch 1 taken 297 times.
70772 else if(tempitem.type == itype_wand)
9232 {
9233
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 279 times.
297 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= item_flag3;
9234 279 else tempitem.flags &= ~ item_flag3;
9235 297 }
9236 72192 }
9237
9238 //Port quest rules to items
9239
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 72192 times.
125440 if( s_version <= 37)
9240 {
9241
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 71910 times.
72192 if(tempitem.type == itype_flippers)
9242 {
9243
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 203 times.
282 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= item_flag1;
9244 203 else tempitem.flags &= ~ item_flag1;
9245 282 }
9246
2/2
✓ Branch 0 taken 54363 times.
✓ Branch 1 taken 17547 times.
71910 else if(tempitem.type == itype_sword)
9247 {
9248
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 17109 times.
17547 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9249 17109 else tempitem.flags &= ~ item_flag5;
9250 17547 }
9251
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 54066 times.
54363 else if(tempitem.type == itype_wand)
9252 {
9253
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 288 times.
297 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9254 288 else tempitem.flags &= ~ item_flag5;
9255 297 }
9256
4/4
✓ Branch 0 taken 53771 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 600 times.
✓ Branch 3 taken 53171 times.
54066 else if(tempitem.type == itype_book || tempitem.type == itype_candle)
9257 {
9258 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9259
2/2
✓ Branch 0 taken 375 times.
✓ Branch 1 taken 520 times.
895 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= item_flag3;
9260 520 else tempitem.flags &= ~ item_flag3;
9261 895 }
9262 72192 }
9263
9264
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 72192 times.
125440 if( s_version < 38)
9265 {
9266
4/4
✓ Branch 0 taken 71348 times.
✓ Branch 1 taken 844 times.
✓ Branch 2 taken 560 times.
✓ Branch 3 taken 70788 times.
72192 if(tempitem.type == itype_brang || tempitem.type == itype_hookshot)
9267 {
9268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1404 times.
1404 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9269 1404 else tempitem.flags &= ~item_flag4;
9270
9271
2/2
✓ Branch 0 taken 673 times.
✓ Branch 1 taken 731 times.
1404 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= item_flag5 | item_flag6;
9272 731 else tempitem.flags &= ~(item_flag5|item_flag6);
9273 1404 }
9274
2/2
✓ Branch 0 taken 69957 times.
✓ Branch 1 taken 831 times.
70788 else if(tempitem.type == itype_arrow)
9275 {
9276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 831 times.
831 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9277 831 else tempitem.flags &= ~item_flag4;
9278
9279
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 435 times.
831 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~item_flag2;
9280 435 else tempitem.flags |= item_flag2;
9281 831 }
9282 72192 }
9283
9284
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 72192 times.
125440 if( s_version < 39)
9285 {
9286
6/6
✓ Branch 0 taken 71913 times.
✓ Branch 1 taken 279 times.
✓ Branch 2 taken 71618 times.
✓ Branch 3 taken 295 times.
✓ Branch 4 taken 600 times.
✓ Branch 5 taken 71018 times.
72192 if(tempitem.type == itype_divinefire || tempitem.type == itype_book || tempitem.type == itype_candle)
9287 {
9288
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1158 times.
1174 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= item_flag5;
9289 1158 else tempitem.flags &= ~item_flag5;
9290 1174 }
9291
2/2
✓ Branch 0 taken 614 times.
✓ Branch 1 taken 70404 times.
71018 else if(tempitem.type == itype_potion)
9292 {
9293
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 452 times.
614 if(get_qr(qr_NONBUBBLEMEDICINE))
9294 {
9295 162 tempitem.flags &= ~(item_flag3|item_flag4);
9296 162 }
9297 else
9298 {
9299 452 tempitem.flags |= item_flag3;
9300
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 333 times.
452 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9301 333 else tempitem.flags &= ~item_flag4;
9302 }
9303 614 }
9304
2/2
✓ Branch 0 taken 69846 times.
✓ Branch 1 taken 558 times.
70404 else if(tempitem.type == itype_triforcepiece)
9305 {
9306
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 474 times.
558 if(get_qr(qr_NONBUBBLETRIFORCE))
9307 {
9308 84 tempitem.flags |= item_flag3;
9309
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
84 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9310 28 else tempitem.flags &= ~item_flag4;
9311 84 }
9312 else
9313 {
9314 474 tempitem.flags &= ~(item_flag3|item_flag4);
9315 }
9316 558 }
9317 72192 }
9318
9319
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 72192 times.
125440 if( s_version < 40)
9320 {
9321
4/4
✓ Branch 0 taken 71275 times.
✓ Branch 1 taken 917 times.
✓ Branch 2 taken 306 times.
✓ Branch 3 taken 70969 times.
72192 if(tempitem.type == itype_ring || tempitem.type == itype_perilring)
9322 {
9323
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 934 times.
1223 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= item_flag1;
9324 934 else tempitem.flags &= ~item_flag1;
9325 1223 }
9326
8/8
✓ Branch 0 taken 70369 times.
✓ Branch 1 taken 600 times.
✓ Branch 2 taken 52822 times.
✓ Branch 3 taken 17547 times.
✓ Branch 4 taken 52525 times.
✓ Branch 5 taken 297 times.
✓ Branch 6 taken 279 times.
✓ Branch 7 taken 52246 times.
70969 else if(tempitem.type == itype_candle || tempitem.type == itype_sword || tempitem.type == itype_wand || tempitem.type == itype_cbyrna)
9327 {
9328
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 18615 times.
18723 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= item_flag8;
9329 18615 else tempitem.flags &= ~item_flag8;
9330 18723 }
9331
6/6
✓ Branch 0 taken 54645 times.
✓ Branch 1 taken 17547 times.
✓ Branch 2 taken 54348 times.
✓ Branch 3 taken 297 times.
✓ Branch 4 taken 282 times.
✓ Branch 5 taken 54066 times.
72192 if(tempitem.type == itype_sword || tempitem.type == itype_wand || tempitem.type == itype_hammer)
9332 {
9333
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 18048 times.
18126 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= item_flag7;
9334 18048 else tempitem.flags &= ~item_flag7;
9335 18126 }
9336
2/2
✓ Branch 0 taken 53787 times.
✓ Branch 1 taken 279 times.
54066 else if(tempitem.type == itype_cbyrna)
9337 {
9338 279 tempitem.flags |= item_flag7;
9339 279 }
9340 72192 }
9341
9342
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 72192 times.
125440 if( s_version < 41 )
9343 {
9344
2/2
✓ Branch 0 taken 54645 times.
✓ Branch 1 taken 17547 times.
72192 if(tempitem.type == itype_sword)
9345 {
9346
2/2
✓ Branch 0 taken 236 times.
✓ Branch 1 taken 17311 times.
17547 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= item_flag9;
9347 17311 else tempitem.flags &= ~item_flag9;
9348
9349
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 17119 times.
17547 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= item_flag10;
9350 17119 else tempitem.flags &= ~item_flag10;
9351 17547 }
9352 72192 }
9353
9354
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 72192 times.
125440 if( s_version < 42 )
9355 {
9356
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 71895 times.
72192 if(tempitem.type == itype_wand)
9357 {
9358
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 279 times.
297 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= item_flag3;
9359 279 else tempitem.flags &= ~item_flag3;
9360
9361 297 tempitem.flags &= ~item_flag6;
9362 297 }
9363
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 71613 times.
71895 else if(tempitem.type == itype_hammer)
9364 {
9365 282 tempitem.flags &= ~item_flag3;
9366 282 }
9367
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 71334 times.
71613 else if(tempitem.type == itype_cbyrna)
9368 {
9369 279 tempitem.flags |= item_flag3;
9370
9371 279 tempitem.flags &= ~item_flag6;
9372 279 }
9373
2/2
✓ Branch 0 taken 53787 times.
✓ Branch 1 taken 17547 times.
71334 else if(tempitem.type == itype_sword)
9374 {
9375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17547 times.
17547 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= item_flag6;
9376 17547 else tempitem.flags &= ~item_flag6;
9377 17547 }
9378 72192 }
9379
9380
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 72192 times.
125440 if( s_version < 43 )
9381 {
9382
2/2
✓ Branch 0 taken 71865 times.
✓ Branch 1 taken 327 times.
72192 if(tempitem.type == itype_whistle)
9383 {
9384
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 317 times.
327 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= item_flag3;
9385 317 else tempitem.flags &= ~item_flag3;
9386 327 }
9387 72192 }
9388
9389
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 72192 times.
125440 if( s_version < 45 )
9390 {
9391
2/2
✓ Branch 0 taken 71910 times.
✓ Branch 1 taken 282 times.
72192 if(tempitem.type == itype_flippers)
9392 {
9393 282 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9394 282 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9395 282 }
9396 72192 }
9397
9398
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 72192 times.
125440 if( s_version < 46 )
9399 {
9400
2/2
✓ Branch 0 taken 71913 times.
✓ Branch 1 taken 279 times.
72192 if(tempitem.type == itype_raft)
9401 {
9402 279 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9403 279 }
9404 72192 }
9405
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 72192 times.
125440 if ( s_version < 34 ) //! set the default counter for older quests.
9406 {
9407
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 72076 times.
72192 if ( (tempitem.flags & item_rupee_magic) )
9408 {
9409 116 tempitem.cost_counter[0] = 1;
9410 116 }
9411 else
9412 {
9413
2/2
✓ Branch 0 taken 42496 times.
✓ Branch 1 taken 29580 times.
72076 if(get_qr(qr_ENABLEMAGIC))
9414 42496 tempitem.cost_counter[0] = 4;
9415 else
9416 {
9417 29580 tempitem.cost_amount[0] = 0;
9418 29580 tempitem.cost_counter[0] = -1;
9419 }
9420 }
9421 72192 }
9422
9423
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 72192 times.
125440 if ( s_version < 35 ) //new Lens of Truth flags
9424 {
9425
2/2
✓ Branch 0 taken 71937 times.
✓ Branch 1 taken 255 times.
72192 if ( tempitem.type == itype_lens )
9426 {
9427
2/2
✓ Branch 0 taken 245 times.
✓ Branch 1 taken 10 times.
255 if ( get_qr(qr_RAFTLENS) )
9428 {
9429 10 tempitem.flags |= item_flag4;
9430 10 }
9431
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 166 times.
255 if ( get_qr(qr_LENSHINTS) )
9432 {
9433 166 tempitem.flags |= item_flag1;
9434 166 }
9435
2/2
✓ Branch 0 taken 242 times.
✓ Branch 1 taken 13 times.
255 if ( get_qr(qr_LENSSEESENEMIES) )
9436 {
9437 13 tempitem.flags |= item_flag5;
9438 13 }
9439 255 }
9440 72192 }
9441
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 72192 times.
125440 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9442 {
9443
2/2
✓ Branch 0 taken 577536 times.
✓ Branch 1 taken 72192 times.
649728 for ( int32_t q = 0; q < 8; q++ )
9444 {
9445 577536 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9446 577536 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9447 577536 tempitem.sprite_initiald[q] = 0;
9448 577536 }
9449 72192 tempitem.sprite_script = 0;
9450 72192 }
9451
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 72192 times.
125440 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9452 {
9453 72192 tempitem.pickupflag = 0;
9454 72192 }
9455
9456
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 72192 times.
125440 if( s_version < 51 )
9457 {
9458
2/2
✓ Branch 0 taken 71592 times.
✓ Branch 1 taken 600 times.
72192 if( tempitem.type == itype_candle )
9459 {
9460 600 tempitem.misc4 = 50; //Step speed
9461 600 }
9462 72192 }
9463
9464
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 72192 times.
125440 if( s_version < 52 )
9465 {
9466
2/2
✓ Branch 0 taken 71334 times.
✓ Branch 1 taken 858 times.
72192 if( tempitem.type == itype_shield )
9467 858 tempitem.flags |= item_flag1; //'Block Front' flag
9468 72192 }
9469
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 72192 times.
125440 if(s_version < 53)
9470 {
9471
4/4
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 70785 times.
✓ Branch 2 taken 831 times.
✓ Branch 3 taken 281 times.
72192 switch(tempitem.type)
9472 {
9473 case itype_arrow:
9474 831 tempitem.cost_counter[1] = crARROWS;
9475 831 tempitem.cost_amount[1] = 1;
9476 831 break;
9477 case itype_bomb:
9478 295 tempitem.cost_counter[1] = crBOMBS;
9479 295 tempitem.cost_amount[1] = 1;
9480 295 break;
9481 case itype_sbomb:
9482 281 tempitem.cost_counter[1] = crSBOMBS;
9483 281 tempitem.cost_amount[1] = 1;
9484 281 break;
9485 default:
9486 70785 tempitem.cost_counter[1] = crNONE;
9487 70785 tempitem.cost_amount[1] = 0;
9488 70785 }
9489 72192 tempitem.magiccosttimer[1] = 0;
9490 72192 }
9491
2/2
✓ Branch 0 taken 50432 times.
✓ Branch 1 taken 75008 times.
125440 if( s_version < 54 )
9492 {
9493
2/2
✓ Branch 0 taken 74713 times.
✓ Branch 1 taken 295 times.
75008 if( tempitem.type == itype_flippers )
9494 295 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9495 75008 }
9496
2/2
✓ Branch 0 taken 50432 times.
✓ Branch 1 taken 75008 times.
125440 if(s_version < 55)
9497 {
9498
3/3
✓ Branch 0 taken 580 times.
✓ Branch 1 taken 580 times.
✓ Branch 2 taken 73848 times.
75008 switch(tempitem.type)
9499 {
9500 case itype_spinscroll:
9501 case itype_quakescroll:
9502 580 tempitem.usesound2 = WAV_ZN1CHARGE;
9503 580 break;
9504 case itype_spinscroll2:
9505 case itype_quakescroll2:
9506 580 tempitem.usesound2 = WAV_ZN1CHARGE2;
9507 580 break;
9508 }
9509 75008 }
9510
2/2
✓ Branch 0 taken 50432 times.
✓ Branch 1 taken 75008 times.
125440 if(s_version < 56)
9511 {
9512
4/4
✓ Branch 0 taken 73786 times.
✓ Branch 1 taken 290 times.
✓ Branch 2 taken 626 times.
✓ Branch 3 taken 306 times.
75008 switch(tempitem.type)
9513 {
9514 case itype_divinefire:
9515
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 11 times.
290 SETFLAG(tempitem.flags, item_flag9, version < 0x255); //Strong Fire
9516
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 208 times.
290 SETFLAG(tempitem.flags, item_flag10, version < 0x250); //Magic Fire
9517 290 tempitem.flags |= item_flag11; //Divine Fire
9518 290 break;
9519 case itype_candle:
9520
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 314 times.
626 SETFLAG(tempitem.flags, item_flag9, tempitem.level > 1); //Strong Fire
9521 626 tempitem.flags &= ~item_flag10; //Magic Fire
9522 626 tempitem.flags &= ~item_flag11; //Divine Fire
9523 626 break;
9524 case itype_book:
9525 306 tempitem.flags |= item_flag9; //Strong Fire
9526 306 tempitem.flags |= item_flag10; //Magic Fire
9527 306 tempitem.flags &= ~item_flag11; //Divine Fire
9528 306 break;
9529 }
9530 75008 }
9531
2/2
✓ Branch 0 taken 41728 times.
✓ Branch 1 taken 83712 times.
125440 if (s_version < 61)
9532 {
9533
2/2
✓ Branch 0 taken 65334 times.
✓ Branch 1 taken 18378 times.
83712 switch (tempitem.type)
9534 {
9535 case itype_sword:
9536 18378 tempitem.usesound2 = WAV_BEAM;
9537 18378 break;
9538 }
9539 83712 }
9540
9541
9542
2/2
✓ Branch 0 taken 10988 times.
✓ Branch 1 taken 114452 times.
125440 if(tempitem.level==0) // Always do this
9543 10988 tempitem.level=1;
9544
9545 125440 itemsbuf[i] = tempitem;
9546 125440 }
9547
9548 490 return 0;
9549 491 }
9550
9551 static bool did_init_def_items = false;
9552 250746 void init_def_items()
9553 {
9554
2/2
✓ Branch 0 taken 250368 times.
✓ Branch 1 taken 378 times.
250746 if(did_init_def_items) return;
9555 378 did_init_def_items = true;
9556 378 default_items[3].cost_counter[1] = crBOMBS;
9557 378 default_items[13].cost_counter[1] = crARROWS;
9558 378 default_items[14].cost_counter[1] = crARROWS;
9559 378 default_items[48].cost_counter[1] = crSBOMBS;
9560 378 default_items[57].cost_counter[1] = crARROWS;
9561 250746 }
9562 250746 void reset_itembuf(itemdata *item, int32_t id)
9563 {
9564 250746 init_def_items();
9565
2/2
✓ Branch 0 taken 105429 times.
✓ Branch 1 taken 145317 times.
250746 if(id<iLast)
9566 {
9567 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9568 145317 word tile = item->tile;
9569 145317 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9570 145317 int32_t ltm = item->ltm;
9571
9572 145317 *item = default_items[id];
9573 145317 item->tile = tile;
9574 145317 item->misc_flags = miscs;
9575 145317 item->csets = cset;
9576 145317 item->frames = frames;
9577 145317 item->speed = speed;
9578 145317 item->delay = delay;
9579 145317 item->ltm = ltm;
9580 145317 }
9581 250746 }
9582
9583 103168 void reset_itemname(int32_t id)
9584 {
9585 103168 sprintf(item_string[id],"zz%03d",id);
9586
9587
2/2
✓ Branch 0 taken 45539 times.
✓ Branch 1 taken 57629 times.
103168 if(id < iLast)
9588 57629 strcpy(item_string[id],old_item_string[id]);
9589 103168 }
9590
9591 491 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9592 {
9593
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 24 times.
491 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_weapons);
9594
9595 491 word weapons_to_read=MAXWPNS;
9596 int32_t dummy;
9597 byte padding;
9598 wpndata tempweapon;
9599 491 word s_version=0;
9600
9601
9602
2/2
✓ Branch 0 taken 485 times.
✓ Branch 1 taken 6 times.
491 if(Header->zelda_version < 0x186)
9603 {
9604 6 weapons_to_read=64;
9605 6 }
9606
9607
2/2
✓ Branch 0 taken 485 times.
✓ Branch 1 taken 6 times.
491 if(Header->zelda_version < 0x185)
9608 {
9609 6 weapons_to_read=32;
9610 6 }
9611
9612
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 467 times.
491 if(Header->zelda_version > 0x192)
9613 {
9614 467 weapons_to_read=0;
9615
9616 //section version info
9617
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if(!p_igetw(&s_version,f))
9618 {
9619 return qe_invalid;
9620 }
9621
9622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if (s_version > V_WEAPONS)
9623 return qe_version;
9624
9625 467 FFCore.quest_format[vWeaponSprites] = s_version;
9626
9627
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if(!read_deprecated_section_cversion(f))
9628 {
9629 return qe_invalid;
9630 }
9631
9632 //section size
9633
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if(!p_igetl(&dummy,f))
9634 {
9635 return qe_invalid;
9636 }
9637
9638 //finally... section data
9639
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if(!p_igetw(&weapons_to_read,f))
9640 {
9641 return qe_invalid;
9642 }
9643
9644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if (weapons_to_read > MAXWPNS)
9645 {
9646 return qe_invalid;
9647 }
9648 467 }
9649
9650
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 83 times.
491 if(s_version>2)
9651 {
9652
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 408 times.
104856 for(int32_t i=0; i<weapons_to_read; i++)
9653 {
9654 char tempname[64];
9655
9656
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if(!pfread(tempname, 64, f))
9657 {
9658 return qe_invalid;
9659 }
9660
9661 104448 weapon_string[i][0] = '\0';
9662 104448 strncat(weapon_string[i], tempname, 64 - 1);
9663 104448 }
9664
9665
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(s_version<4)
9666 {
9667 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9668 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9669 }
9670
9671
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(s_version<5)
9672 {
9673 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9674 }
9675
9676 /*
9677 if (s_version<6)
9678 {
9679 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9680 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9681 }
9682 */
9683 408 }
9684
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
9685 {
9686
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXWPNS; i++)
9687 20992 reset_weaponname(i);
9688 82 }
9689
9690
2/2
✓ Branch 0 taken 113260 times.
✓ Branch 1 taken 491 times.
113751 for(int32_t i=0; i<weapons_to_read; i++)
9691 {
9692 113260 word oldtile = 0;
9693
2/2
✓ Branch 0 taken 51968 times.
✓ Branch 1 taken 61292 times.
113260 if (s_version < 8)
9694 {
9695
1/2
✓ Branch 0 taken 61292 times.
✗ Branch 1 not taken.
61292 if (!p_igetw(&oldtile, f))
9696 return qe_invalid;
9697 61292 }
9698
9699
1/2
✓ Branch 0 taken 113260 times.
✗ Branch 1 not taken.
113260 if(!p_getc(&tempweapon.misc,f))
9700 {
9701 return qe_invalid;
9702 }
9703
9704
1/2
✓ Branch 0 taken 113260 times.
✗ Branch 1 not taken.
113260 if(!p_getc(&tempweapon.csets,f))
9705 {
9706 return qe_invalid;
9707 }
9708
9709
1/2
✓ Branch 0 taken 113260 times.
✗ Branch 1 not taken.
113260 if(!p_getc(&tempweapon.frames,f))
9710 {
9711 return qe_invalid;
9712 }
9713
9714
1/2
✓ Branch 0 taken 113260 times.
✗ Branch 1 not taken.
113260 if(!p_getc(&tempweapon.speed,f))
9715 {
9716 return qe_invalid;
9717 }
9718
9719
1/2
✓ Branch 0 taken 113260 times.
✗ Branch 1 not taken.
113260 if(!p_getc(&tempweapon.type,f))
9720 {
9721 return qe_invalid;
9722 }
9723
9724
2/2
✓ Branch 0 taken 60012 times.
✓ Branch 1 taken 53248 times.
113260 if ( s_version >= 7 )
9725 {
9726
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if(!p_igetw(&tempweapon.script,f))
9727 {
9728 return qe_invalid;
9729 }
9730
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if(!p_igetl(&tempweapon.tile,f))
9731 {
9732 return qe_invalid;
9733 }
9734 53248 }
9735
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 60012 times.
113260 if ( s_version < 7 )
9736 {
9737 60012 tempweapon.tile = oldtile;
9738 60012 }
9739
9740
2/2
✓ Branch 0 taken 108460 times.
✓ Branch 1 taken 4800 times.
113260 if(Header->zelda_version < 0x193)
9741 {
9742
1/2
✓ Branch 0 taken 4800 times.
✗ Branch 1 not taken.
4800 if(!p_getc(&padding,f))
9743 {
9744 return qe_invalid;
9745 }
9746 4800 }
9747
9748
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 8812 times.
113260 if(s_version < 6)
9749 {
9750
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 8794 times.
8812 if(i==ewFIRETRAIL)
9751 {
9752 18 tempweapon.misc |= WF_BEHIND;
9753 18 }
9754 else
9755 8794 tempweapon.misc &= ~WF_BEHIND;
9756 8812 }
9757
9758
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 113004 times.
113260 if (!should_skip)
9759 113004 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9760 113260 }
9761
9762
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 490 times.
491 if (should_skip)
9763 1 return 0;
9764
9765
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 82 times.
490 if(s_version<2)
9766 {
9767 82 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9768 82 }
9769
9770
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 82 times.
490 if(s_version<5)
9771 {
9772 82 wpnsbuf[iwQuarterHearts].tile=1;
9773 82 wpnsbuf[iwQuarterHearts].csets=1;
9774 82 }
9775
9776
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 if(Header->zelda_version < 0x176)
9777 {
9778 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9779 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9780 itemsbuf[iMisc1].clear();
9781 itemsbuf[iMisc2].clear();
9782 }
9783
9784
3/4
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
495 if((Header->zelda_version < 0x192)||
9785
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 467 times.
472 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9786 {
9787 18 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9788 18 }
9789
9790
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 23 times.
490 if((Header->zelda_version < 0x210))
9791 {
9792 23 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9793 23 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9794 23 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9795 23 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9796 23 }
9797
9798 490 return 0;
9799 491 }
9800
9801 223102 static void guy_update_firesfx(guydata& tempguy)
9802 {
9803 223102 tempguy.firesfx = 0;
9804
2/2
✓ Branch 0 taken 6495 times.
✓ Branch 1 taken 216607 times.
223102 if (tempguy.type == eeWIZZ)
9805 {
9806
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 981 times.
✓ Branch 2 taken 3970 times.
✓ Branch 3 taken 836 times.
✓ Branch 4 taken 708 times.
6495 switch (tempguy.attributes[1])
9807 {
9808 case 0: // normal weapon
9809 3970 tempguy.firesfx = WAV_WAND;
9810 3970 break;
9811 case 1: // 8 shots
9812
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 754 times.
836 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) tempguy.firesfx = WAV_FIRE;
9813 else
9814 {
9815
3/8
✓ Branch 0 taken 650 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
754 switch (tempguy.weapon)
9816 {
9817 case ewFireTrail:
9818 case ewFlame:
9819 case ewFlame2Trail:
9820 case ewFlame2:
9821 650 tempguy.firesfx = WAV_FIRE;
9822 650 break;
9823 case ewWind:
9824 case ewMagic:
9825 88 tempguy.firesfx = WAV_WAND;
9826 88 break;
9827 case ewIce:
9828 tempguy.firesfx = WAV_ZN1ICE;
9829 break;
9830 case ewRock:
9831 tempguy.firesfx = WAV_ZN1ROCK;
9832 break;
9833 case ewFireball2:
9834 case ewFireball:
9835 16 tempguy.firesfx = WAV_ZN1FIREBALL;
9836 16 break;
9837 case ewBrang:
9838 tempguy.firesfx = WAV_BRANG;
9839 break;
9840 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9841 tempguy.firesfx = WAV_BOMB;
9842 break;
9843 default:
9844 tempguy.firesfx = 0;
9845 break;
9846 }
9847 754 break;
9848 }
9849 case 2: // Summon
9850 1063 tempguy.firesfx = WAV_FIRE;
9851 1063 break;
9852 case 3: // Summon Layer
9853 708 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
9854 708 break;
9855 }
9856 6495 }
9857 else
9858 {
9859
6/6
✓ Branch 0 taken 163317 times.
✓ Branch 1 taken 53290 times.
✓ Branch 2 taken 42354 times.
✓ Branch 3 taken 205671 times.
✓ Branch 4 taken 47824 times.
✓ Branch 5 taken 47820 times.
216607 if ((tempguy.type == eeWALK || tempguy.type == eePROJECTILE) && (tempguy.attributes[0] == e1tSUMMON || tempguy.attributes[0] == e1tSUMMONLAYER))
9860 {
9861 95644 tempguy.firesfx = get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE;
9862 95644 }
9863 else
9864 {
9865
7/8
✓ Branch 0 taken 9721 times.
✓ Branch 1 taken 2381 times.
✓ Branch 2 taken 1816 times.
✓ Branch 3 taken 12951 times.
✓ Branch 4 taken 172511 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4001 times.
✓ Branch 7 taken 2290 times.
205671 switch (tempguy.weapon)
9866 {
9867 case ewFireTrail:
9868 case ewFlame:
9869 case ewFlame2Trail:
9870 case ewFlame2:
9871 9721 tempguy.firesfx = WAV_FIRE;
9872 9721 break;
9873 case ewWind:
9874 case ewMagic:
9875 1816 tempguy.firesfx = WAV_WAND;
9876 1816 break;
9877 case ewIce:
9878 tempguy.firesfx = WAV_ZN1ICE;
9879 break;
9880 case ewRock:
9881 4001 tempguy.firesfx = WAV_ZN1ROCK;
9882 4001 break;
9883 case ewFireball2:
9884 case ewFireball:
9885 12951 tempguy.firesfx = WAV_ZN1FIREBALL;
9886 12951 break;
9887 case ewBrang:
9888 2290 tempguy.firesfx = WAV_BRANG;
9889 2290 break;
9890 case ewBomb:case ewSBomb: case ewLitBomb:case ewLitSBomb:
9891 2381 tempguy.firesfx = WAV_BOMB;
9892 2381 break;
9893 default:
9894 172511 tempguy.firesfx = 0;
9895 172511 break;
9896 }
9897 }
9898 }
9899 212170 }
9900
9901 212170 static void guy_update_weaponflags(guydata& tempguy)
9902 {
9903 212170 tempguy.weap_data.unblockable = 0;
9904 212170 tempguy.weap_data.moveflags = move_none;
9905
4/4
✓ Branch 0 taken 205572 times.
✓ Branch 1 taken 6598 times.
✓ Branch 2 taken 3036 times.
✓ Branch 3 taken 202536 times.
212170 if (tempguy.weapon == ewFlame || tempguy.weapon == ewFireTrail)
9906 9634 tempguy.weap_data.moveflags |= (move_obeys_grav | move_can_pitfall);
9907 212170 tempguy.weap_data.override_flags = 0;
9908 212170 tempguy.weap_data.hxofs = 0;
9909 212170 tempguy.weap_data.hyofs = 0;
9910 212170 tempguy.weap_data.hxsz = 0;
9911 212170 tempguy.weap_data.hysz = 0;
9912 212170 tempguy.weap_data.hzsz = 0;
9913 212170 tempguy.weap_data.xofs = 0;
9914 212170 tempguy.weap_data.yofs = 0;
9915 212170 tempguy.weap_data.tilew = 0;
9916 212170 tempguy.weap_data.tileh = 0;
9917
5/5
✓ Branch 0 taken 2530 times.
✓ Branch 1 taken 170520 times.
✓ Branch 2 taken 18693 times.
✓ Branch 3 taken 12967 times.
✓ Branch 4 taken 7460 times.
212170 switch (tempguy.weapon)
9918 {
9919 case ewFireball: case ewFireball2:
9920 12967 tempguy.weap_data.step = 1.75_zf;
9921 12967 break;
9922 case ewSword: case ewLitBomb: case ewLitSBomb:
9923 case ewRock: case ewMagic: case ewWind:
9924 18693 tempguy.weap_data.step = 3_zf;
9925 18693 break;
9926 case ewArrow:
9927 2530 tempguy.weap_data.step = 2_zf;
9928 2530 break;
9929 case ewFlame: case ewFlame2:
9930 7460 tempguy.weap_data.step = 1_zf;
9931 7460 break;
9932 default:
9933 170520 tempguy.weap_data.step = 0_zf;
9934 170520 break;
9935 }
9936
2/2
✓ Branch 0 taken 1060850 times.
✓ Branch 1 taken 212170 times.
1273020 for (int q = 0; q < WPNSPR_MAX; ++q)
9937 {
9938 1060850 tempguy.weap_data.burnsprs[q] = 0;
9939 1060850 tempguy.weap_data.light_rads[q] = 0;
9940 1060850 }
9941 212170 }
9942
9943 212170 static void guy_update_weaponspecialsfx(guydata& tempguy)
9944 {
9945
3/3
✓ Branch 0 taken 2290 times.
✓ Branch 1 taken 207444 times.
✓ Branch 2 taken 2436 times.
212170 switch (tempguy.weapon)
9946 {
9947 case ewBrang:
9948 2290 tempguy.specialsfx = WAV_BRANG;
9949 2290 break;
9950 case ewBomb: case ewSBomb: case ewLitBomb:case ewLitSBomb:
9951 2436 tempguy.specialsfx = WAV_BOMB;
9952 2436 break;
9953 default:
9954 207444 tempguy.specialsfx = 0;
9955 207444 break;
9956 }
9957 212170 }
9958
9959 490 void init_guys(int32_t guyversion)
9960 {
9961
2/2
✓ Branch 0 taken 250880 times.
✓ Branch 1 taken 490 times.
251370 for(int32_t i=0; i<MAXGUYS; i++)
9962 {
9963 250880 guysbuf[i] = default_guys[0];
9964 250880 }
9965
9966
2/2
✓ Branch 0 taken 86730 times.
✓ Branch 1 taken 490 times.
87220 for(int32_t i=0; i<OLDMAXGUYS; i++)
9967 {
9968 86730 guysbuf[i] = default_guys[i];
9969
2/2
✓ Branch 0 taken 85750 times.
✓ Branch 1 taken 980 times.
86730 guysbuf[i].spr_shadow = (guysbuf[i].type==eeROCK && guysbuf[i].attributes[9] == 1) ? iwLargeShadow : iwShadow;
9970 86730 guysbuf[i].spr_death = iwDeath;
9971 86730 guysbuf[i].spr_spawn = iwSpawn;
9972 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9973
4/4
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 72216 times.
✓ Branch 2 taken 14432 times.
✓ Branch 3 taken 82 times.
86730 if(guyversion<=3 && i==ePATRABS)
9974 {
9975 82 guysbuf[i].bosspal=spDIG;
9976 82 guysbuf[i].cset=14;
9977 82 guysbuf[i].attributes[8] = 14;
9978 82 }
9979
9980
2/2
✓ Branch 0 taken 72216 times.
✓ Branch 1 taken 14514 times.
86730 if(guyversion<=3)
9981 {
9982 // Rope/Ghini Flash rules
9983
2/2
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 10443 times.
14514 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9984 {
9985
2/2
✓ Branch 0 taken 10384 times.
✓ Branch 1 taken 59 times.
10443 if(i==eROPE2)
9986 {
9987 59 guysbuf[i].flags &= ~guy_flashing;
9988 59 }
9989 10443 }
9990
9991
2/2
✓ Branch 0 taken 12390 times.
✓ Branch 1 taken 2124 times.
14514 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9992 {
9993
12/12
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2100 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 2088 times.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 2076 times.
✓ Branch 7 taken 12 times.
✓ Branch 8 taken 2064 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 2052 times.
2124 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9994 {
9995 72 guysbuf[i].flags &= ~guy_flashing;
9996 72 }
9997 2124 }
9998
9999
2/2
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
14514 if(i==eGHINI2)
10000 {
10001
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 4 times.
82 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
10002 {
10003 4 guysbuf[i].flags |= guy_blinking;
10004 4 }
10005
10006
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 38 times.
82 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
10007 {
10008 38 guysbuf[i].flags |= guy_transparent;
10009 38 }
10010 82 }
10011
10012
4/4
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 14350 times.
14514 if (i == eDIG1 || i == eDIG3)
10013 {
10014 164 guysbuf[i].flags |= guy_ignore_kill_all;
10015 164 }
10016 14514 }
10017
10018 // Darknut fix
10019
10/10
✓ Branch 0 taken 86240 times.
✓ Branch 1 taken 490 times.
✓ Branch 2 taken 85750 times.
✓ Branch 3 taken 490 times.
✓ Branch 4 taken 85260 times.
✓ Branch 5 taken 490 times.
✓ Branch 6 taken 84770 times.
✓ Branch 7 taken 490 times.
✓ Branch 8 taken 490 times.
✓ Branch 9 taken 84280 times.
86730 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
10020 {
10021
2/2
✓ Branch 0 taken 2040 times.
✓ Branch 1 taken 410 times.
2450 if(get_qr(qr_NEWENEMYTILES))
10022 {
10023 2040 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
10024 2040 guysbuf[i].s_width=guysbuf[i].e_width;
10025 2040 guysbuf[i].s_height=guysbuf[i].e_height;
10026 2040 }
10027 410 else guysbuf[i].s_tile=860;
10028
10029
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 2130 times.
2450 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
10030 2130 guysbuf[i].flags &= ~guy_bkshield;
10031 else
10032 320 guysbuf[i].flags |= guy_bkshield;
10033 2450 }
10034
10035
4/4
✓ Branch 0 taken 86240 times.
✓ Branch 1 taken 490 times.
✓ Branch 2 taken 86680 times.
✓ Branch 3 taken 50 times.
86730 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
10036 {
10037 50 guysbuf[i].attributes[2] = (i == eFGELTRIB ? eFZOL : eZOL);
10038 50 }
10039
10040 86730 guy_update_firesfx(guysbuf[i]);
10041 86730 guy_update_weaponflags(guysbuf[i]);
10042 86730 guy_update_weaponspecialsfx(guysbuf[i]);
10043 86730 }
10044 490 }
10045
10046 20992 void reset_weaponname(int32_t i)
10047 {
10048
2/2
✓ Branch 0 taken 7216 times.
✓ Branch 1 taken 13776 times.
20992 if(i<wLast)
10049 {
10050 7216 strcpy(weapon_string[i],old_weapon_string[i]);
10051 7216 }
10052 else
10053 13776 sprintf(weapon_string[i],"zz%03d",i);
10054 20992 }
10055
10056 490 void init_item_drop_sets()
10057 {
10058
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 490 times.
125930 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
10059 {
10060 // item_drop_sets[i] = default_item_drop_sets[0];
10061 125440 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
10062 125440 }
10063
10064
2/2
✓ Branch 0 taken 6370 times.
✓ Branch 1 taken 490 times.
6860 for(int32_t i=0; i<isMAX; i++)
10065 {
10066 6370 item_drop_sets[i] = default_item_drop_sets[i];
10067
10068 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
10069
2/2
✓ Branch 0 taken 63700 times.
✓ Branch 1 taken 6370 times.
70070 for(int32_t j=0; j<10; ++j)
10070 {
10071 63700 int32_t it = item_drop_sets[i].item[j];
10072
10073
3/4
✓ Branch 0 taken 44804 times.
✓ Branch 1 taken 18896 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2892 times.
63700 if((itemsbuf[it].type == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
10074
2/2
✓ Branch 0 taken 2892 times.
✓ Branch 1 taken 41912 times.
44804 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
10075 {
10076 2892 item_drop_sets[i].chance[j+1]=0;
10077 2892 }
10078
4/4
✓ Branch 0 taken 1960 times.
✓ Branch 1 taken 58848 times.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 1816 times.
60808 else if(itemsbuf[it].type == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
10079 {
10080 144 item_drop_sets[i].chance[j+1]=0;
10081 144 }
10082
10083 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
10084
2/2
✓ Branch 0 taken 63676 times.
✓ Branch 1 taken 24 times.
63700 if(itemsbuf[it].type == itype_misc)
10085 {
10086 // If a non-gameplay item was selected, then item drop was aborted.
10087 // Reflect this by increasing the 'Nothing' chance accordingly.
10088 24 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
10089 24 item_drop_sets[i].chance[j+1]=0;
10090 24 }
10091 63700 }
10092 6370 }
10093 490 }
10094
10095 490 void init_favorites()
10096 {
10097
2/2
✓ Branch 0 taken 617400 times.
✓ Branch 1 taken 490 times.
617890 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
10098 {
10099 617400 favorite_combos[i]=-1;
10100 617400 }
10101 490 }
10102
10103 777 int32_t init_combo_classes()
10104 {
10105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 777 times.
777 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
10106
2/2
✓ Branch 0 taken 142968 times.
✓ Branch 1 taken 777 times.
143745 for(int32_t i=0; i<cMAX; i++)
10107 {
10108 142968 combo_class_buf[i] = default_combo_classes[i];
10109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142968 times.
142968 if ( char const* nm = zi->getComboTypeName(i) )
10110 {
10111 142968 size_t len = strlen(nm);
10112
2/2
✓ Branch 0 taken 9149952 times.
✓ Branch 1 taken 142968 times.
9292920 for ( size_t q = 0; q < 64; q++ )
10113 {
10114
2/2
✓ Branch 0 taken 2095569 times.
✓ Branch 1 taken 7054383 times.
9149952 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
10115 9149952 }
10116 142968 }
10117 142968 }
10118
10119 777 return 0;
10120 }
10121
10122 305 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites)
10123 {
10124
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 259 times.
305 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_herosprites);
10125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 305 times.
305 if (should_skip) return 0;
10126
10127
1/2
✓ Branch 0 taken 305 times.
✗ Branch 1 not taken.
305 assert(v_herosprites < 6);
10128
10129 305 zinit.hero_swim_speed=67; //default
10130 305 setupherotiles(zinit.heroAnimationStyle);
10131 305 setupherodefenses();
10132 305 setupherooffsets();
10133
10134
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 200 times.
305 if(v_herosprites>=0)
10135 {
10136 word tile, tile2;
10137 byte flip, extend, dummy_byte;
10138
10139
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10140 {
10141
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10142 {
10143 return qe_invalid;
10144 }
10145
10146
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10147 {
10148 return qe_invalid;
10149 }
10150
10151
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10152 {
10153 return qe_invalid;
10154 }
10155
10156 800 walkspr[i][spr_tile]=(int32_t)tile;
10157 800 walkspr[i][spr_flip]=(int32_t)flip;
10158 800 walkspr[i][spr_extend]=(int32_t)extend;
10159 800 }
10160
10161
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10162 {
10163
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10164 {
10165 return qe_invalid;
10166 }
10167
10168
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10169 {
10170 return qe_invalid;
10171 }
10172
10173
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10174 {
10175 return qe_invalid;
10176 }
10177
10178 800 stabspr[i][spr_tile]=(int32_t)tile;
10179 800 stabspr[i][spr_flip]=(int32_t)flip;
10180 800 stabspr[i][spr_extend]=(int32_t)extend;
10181 800 }
10182
10183
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10184 {
10185
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10186 {
10187 return qe_invalid;
10188 }
10189
10190
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10191 {
10192 return qe_invalid;
10193 }
10194
10195
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10196 {
10197 return qe_invalid;
10198 }
10199
10200 800 slashspr[i][spr_tile]=(int32_t)tile;
10201 800 slashspr[i][spr_flip]=(int32_t)flip;
10202 800 slashspr[i][spr_extend]=(int32_t)extend;
10203 800 }
10204
10205
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10206 {
10207
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10208 {
10209 return qe_invalid;
10210 }
10211
10212
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10213 {
10214 return qe_invalid;
10215 }
10216
10217
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10218 {
10219 return qe_invalid;
10220 }
10221
10222 800 floatspr[i][spr_tile]=(int32_t)tile;
10223 800 floatspr[i][spr_flip]=(int32_t)flip;
10224 800 floatspr[i][spr_extend]=(int32_t)extend;
10225 800 }
10226
10227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>1)
10228 {
10229
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10230 {
10231
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10232 {
10233 return qe_invalid;
10234 }
10235
10236
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10237 {
10238 return qe_invalid;
10239 }
10240
10241
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10242 {
10243 return qe_invalid;
10244 }
10245
10246 800 swimspr[i][spr_tile]=(int32_t)tile;
10247 800 swimspr[i][spr_flip]=(int32_t)flip;
10248 800 swimspr[i][spr_extend]=(int32_t)extend;
10249 800 }
10250 200 }
10251
10252
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10253 {
10254
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10255 {
10256 return qe_invalid;
10257 }
10258
10259
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10260 {
10261 return qe_invalid;
10262 }
10263
10264
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10265 {
10266 return qe_invalid;
10267 }
10268
10269 800 divespr[i][spr_tile]=(int32_t)tile;
10270 800 divespr[i][spr_flip]=(int32_t)flip;
10271 800 divespr[i][spr_extend]=(int32_t)extend;
10272 800 }
10273
10274
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10275 {
10276
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10277 {
10278 return qe_invalid;
10279 }
10280
10281
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10282 {
10283 return qe_invalid;
10284 }
10285
10286
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10287 {
10288 return qe_invalid;
10289 }
10290
10291 800 poundspr[i][spr_tile]=(int32_t)tile;
10292 800 poundspr[i][spr_flip]=(int32_t)flip;
10293 800 poundspr[i][spr_extend]=(int32_t)extend;
10294 800 }
10295
10296
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_igetw(&tile,f))
10297 {
10298 return qe_invalid;
10299 }
10300
10301 200 flip=0;
10302
10303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>0)
10304 {
10305
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&flip,f))
10306 {
10307 return qe_invalid;
10308 }
10309 200 }
10310
10311
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&extend,f))
10312 {
10313 return qe_invalid;
10314 }
10315
10316 200 castingspr[spr_tile]=(int32_t)tile;
10317 200 castingspr[spr_flip]=(int32_t)flip;
10318 200 castingspr[spr_extend]=(int32_t)extend;
10319
10320
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(v_herosprites>0)
10321 {
10322 200 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10323
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 200 times.
600 for(int32_t i=0; i<2; i++)
10324 {
10325
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 400 times.
1200 for(int32_t j=0; j<num_holdsprs; j++)
10326 {
10327
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10328 {
10329 return qe_invalid;
10330 }
10331
10332
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10333 {
10334 return qe_invalid;
10335 }
10336
10337
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10338 {
10339 return qe_invalid;
10340 }
10341
10342 800 holdspr[i][j][spr_tile]=(int32_t)tile;
10343 800 holdspr[i][j][spr_flip]=(int32_t)flip;
10344 800 holdspr[i][j][spr_extend]=(int32_t)extend;
10345 800 }
10346 400 }
10347 200 }
10348 else
10349 {
10350 for(int32_t i=0; i<2; i++)
10351 {
10352 if(!p_igetw(&tile,f))
10353 {
10354 return qe_invalid;
10355 }
10356
10357 if(!p_igetw(&tile2,f))
10358 {
10359 return qe_invalid;
10360 }
10361
10362 if(!p_getc(&extend,f))
10363 {
10364 return qe_invalid;
10365 }
10366
10367 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10368 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10369 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10370 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10371 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10372 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10373 }
10374 }
10375
10376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>2)
10377 {
10378
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10379 {
10380
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10381 {
10382 return qe_invalid;
10383 }
10384
10385
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10386 {
10387 return qe_invalid;
10388 }
10389
10390
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&extend,f))
10391 {
10392 return qe_invalid;
10393 }
10394
10395 800 jumpspr[i][spr_tile]=(int32_t)tile;
10396 800 jumpspr[i][spr_flip]=(int32_t)flip;
10397 800 jumpspr[i][spr_extend]=(int32_t)extend;
10398 800 }
10399 200 }
10400
10401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>3)
10402 {
10403
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i=0; i<4; i++)
10404 {
10405
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetw(&tile,f))
10406 {
10407 return qe_invalid;
10408 }
10409
10410
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_getc(&flip,f))
10411 {
10412 return qe_invalid;
10413 }
10414
10415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 if(!p_getc(&extend,f))
10416 {
10417 return qe_invalid;
10418 }
10419
10420 800 chargespr[i][spr_tile]=(int32_t)tile;
10421 800 chargespr[i][spr_flip]=(int32_t)flip;
10422 800 chargespr[i][spr_extend]=(int32_t)extend;
10423 800 }
10424 200 }
10425
10426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(v_herosprites>4)
10427 {
10428
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&dummy_byte,f))
10429 {
10430 return qe_invalid;
10431 }
10432
10433 200 zinit.hero_swim_speed=(byte)dummy_byte;
10434 200 }
10435
10436 200 memset(frozenspr, 0, sizeof(frozenspr));
10437 200 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10438 200 memset(onfirespr, 0, sizeof(onfirespr));
10439 200 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10440 200 memset(diggingspr, 0, sizeof(diggingspr));
10441 200 memset(usingrodspr, 0, sizeof(usingrodspr));
10442 200 memset(usingcanespr, 0, sizeof(usingcanespr));
10443 200 memset(pushingspr, 0, sizeof(pushingspr));
10444 200 memset(liftingspr, 0, sizeof(liftingspr));
10445 200 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10446 200 memset(stunnedspr, 0, sizeof(stunnedspr));
10447 200 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10448 200 memset(fallingspr, 0, sizeof(fallingspr));
10449 200 memset(shockedspr, 0, sizeof(shockedspr));
10450 200 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10451 200 memset(pullswordspr, 0, sizeof(pullswordspr));
10452 200 memset(readingspr, 0, sizeof(readingspr));
10453 200 memset(slash180spr, 0, sizeof(slash180spr));
10454 200 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10455 200 memset(dashspr, 0, sizeof(dashspr));
10456 200 memset(bonkspr, 0, sizeof(bonkspr));
10457 200 memset(medallionsprs, 0, sizeof(medallionsprs));
10458 200 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10459 200 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10460
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t q = 0; q < 4; ++q)
10461 {
10462
2/2
✓ Branch 0 taken 2400 times.
✓ Branch 1 taken 800 times.
3200 for(int32_t p = 0; p < 3; ++p)
10463 {
10464 2400 drowningspr[q][p] = divespr[q][p];
10465 2400 drowning_lavaspr[q][p] = divespr[q][p];
10466 2400 }
10467 800 }
10468 200 memset(sideswimspr, 0, sizeof(sideswimspr));
10469 200 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10470 200 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10471 200 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10472 200 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10473 200 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10474 200 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10475 200 }
10476
10477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 305 times.
305 if(FFCore.quest_format[vInitData] < 34)
10478 {
10479 305 bool fastswim = zinit.hero_swim_speed > 60;
10480 // '2/3' or '1/2'
10481 305 zinit.hero_swim_mult = fastswim ? 2 : 1;
10482 305 zinit.hero_swim_div = fastswim ? 3 : 2;
10483 305 }
10484 305 return 0;
10485 305 }
10486
10487 35360 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10488 {
10489 35360 arr[spr_tile] = tile;
10490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35360 times.
35360 arr[spr_flip] = (flip > 3 ? 0 : flip);
10491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35360 times.
35360 arr[spr_extend] = (ext > 2 ? 0 : ext);
10492 35360 }
10493 //Used to read the player sprites as int32_t, not word.
10494 208 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites)
10495 {
10496 208 zinit.hero_swim_speed=67; //default
10497 208 setupherotiles(zinit.heroAnimationStyle);
10498 208 setupherodefenses();
10499 208 setupherooffsets();
10500
10501 int32_t tile, tile2;
10502 byte flip, extend, dummy_byte;
10503
10504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
208 if(v_herosprites>=0)
10505 {
10506
10507
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t i=0; i<4; i++)
10508 {
10509
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10510 {
10511 return qe_invalid;
10512 }
10513
10514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
10515 {
10516 return qe_invalid;
10517 }
10518
10519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
10520 {
10521 return qe_invalid;
10522 }
10523
10524 832 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10525 832 }
10526
10527
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t i=0; i<4; i++)
10528 {
10529
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10530 {
10531 return qe_invalid;
10532 }
10533
10534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
10535 {
10536 return qe_invalid;
10537 }
10538
10539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
10540 {
10541 return qe_invalid;
10542 }
10543
10544 832 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10545 832 }
10546
10547
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t i=0; i<4; i++)
10548 {
10549
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10550 {
10551 return qe_invalid;
10552 }
10553
10554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
10555 {
10556 return qe_invalid;
10557 }
10558
10559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
10560 {
10561 return qe_invalid;
10562 }
10563
10564 832 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10565 832 }
10566
10567
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t i=0; i<4; i++)
10568 {
10569
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10570 {
10571 return qe_invalid;
10572 }
10573
10574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
10575 {
10576 return qe_invalid;
10577 }
10578
10579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
10580 {
10581 return qe_invalid;
10582 }
10583
10584 832 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10585 832 }
10586
10587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
208 if(v_herosprites>1)
10588 {
10589
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t i=0; i<4; i++)
10590 {
10591
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10592 {
10593 return qe_invalid;
10594 }
10595
10596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
10597 {
10598 return qe_invalid;
10599 }
10600
10601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
10602 {
10603 return qe_invalid;
10604 }
10605
10606 832 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10607 832 }
10608 208 }
10609
10610
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t i=0; i<4; i++)
10611 {
10612
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10613 {
10614 return qe_invalid;
10615 }
10616
10617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
10618 {
10619 return qe_invalid;
10620 }
10621
10622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
10623 {
10624 return qe_invalid;
10625 }
10626
10627 832 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10628 832 }
10629
10630
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t i=0; i<4; i++)
10631 {
10632
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10633 {
10634 return qe_invalid;
10635 }
10636
10637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
10638 {
10639 return qe_invalid;
10640 }
10641
10642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
10643 {
10644 return qe_invalid;
10645 }
10646
10647 832 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10648 832 }
10649
10650
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if(!p_igetl(&tile,f))
10651 {
10652 return qe_invalid;
10653 }
10654
10655 208 flip=0;
10656
10657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
208 if(v_herosprites>0)
10658 {
10659
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if(!p_getc(&flip,f))
10660 {
10661 return qe_invalid;
10662 }
10663 208 }
10664
10665
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if(!p_getc(&extend,f))
10666 {
10667 return qe_invalid;
10668 }
10669
10670 208 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10671
10672
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if(v_herosprites>0)
10673 {
10674 208 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10675
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 208 times.
624 for(int32_t i=0; i<2; i++)
10676 {
10677
2/2
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 416 times.
1664 for(int32_t j=0; j<num_holdsprs; j++)
10678 {
10679
1/2
✓ Branch 0 taken 1248 times.
✗ Branch 1 not taken.
1248 if(!p_igetl(&tile,f))
10680 {
10681 return qe_invalid;
10682 }
10683
10684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1248 times.
1248 if(!p_getc(&flip,f))
10685 {
10686 return qe_invalid;
10687 }
10688
10689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1248 times.
1248 if(!p_getc(&extend,f))
10690 {
10691 return qe_invalid;
10692 }
10693
10694 1248 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10695 1248 }
10696 416 }
10697 208 }
10698 else
10699 {
10700 for(int32_t i=0; i<2; i++)
10701 {
10702 if(!p_igetl(&tile,f))
10703 {
10704 return qe_invalid;
10705 }
10706
10707 if(!p_igetl(&tile2,f))
10708 {
10709 return qe_invalid;
10710 }
10711
10712 if(!p_getc(&extend,f))
10713 {
10714 return qe_invalid;
10715 }
10716
10717 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10718 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10719 }
10720 }
10721
10722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
208 if(v_herosprites>2)
10723 {
10724
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t i=0; i<4; i++)
10725 {
10726
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10727 {
10728 return qe_invalid;
10729 }
10730
10731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
10732 {
10733 return qe_invalid;
10734 }
10735
10736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
10737 {
10738 return qe_invalid;
10739 }
10740
10741 832 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10742 832 }
10743 208 }
10744
10745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
208 if(v_herosprites>3)
10746 {
10747
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t i=0; i<4; i++)
10748 {
10749
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10750 {
10751 return qe_invalid;
10752 }
10753
10754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
10755 {
10756 return qe_invalid;
10757 }
10758
10759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
10760 {
10761 return qe_invalid;
10762 }
10763
10764 832 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10765 832 }
10766 208 }
10767
10768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
208 if(v_herosprites>4)
10769 {
10770
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if(!p_getc(&dummy_byte,f))
10771 {
10772 return qe_invalid;
10773 }
10774
10775 208 zinit.hero_swim_speed=(byte)dummy_byte;
10776 208 }
10777
10778
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if(v_herosprites>6)
10779 {
10780
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
10781 {
10782
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10783 return qe_invalid;
10784
10785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
10786 return qe_invalid;
10787
10788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
10789 return qe_invalid;
10790
10791 832 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10792 832 }
10793
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
10794 {
10795
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10796 return qe_invalid;
10797
10798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
10799 return qe_invalid;
10800
10801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
10802 return qe_invalid;
10803
10804 832 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10805 832 }
10806
10807
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
10808 {
10809
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10810 return qe_invalid;
10811
10812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
10813 return qe_invalid;
10814
10815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
10816 return qe_invalid;
10817
10818 832 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10819 832 }
10820
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
10821 {
10822
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10823 return qe_invalid;
10824
10825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
10826 return qe_invalid;
10827
10828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
10829 return qe_invalid;
10830
10831 832 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10832 832 }
10833
10834
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
10835 {
10836
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10837 return qe_invalid;
10838
10839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
10840 return qe_invalid;
10841
10842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
10843 return qe_invalid;
10844
10845 832 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10846 832 }
10847
10848
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
10849 {
10850
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10851 return qe_invalid;
10852
10853
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&flip,f))
10854 return qe_invalid;
10855
10856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
10857 return qe_invalid;
10858
10859 832 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10860 832 }
10861
10862
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
10863 {
10864
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10865 return qe_invalid;
10866
10867
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&flip,f))
10868 return qe_invalid;
10869
10870
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&extend,f))
10871 return qe_invalid;
10872
10873 832 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10874 832 }
10875
10876
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
10877 {
10878
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10879 return qe_invalid;
10880
10881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
10882 return qe_invalid;
10883
10884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
10885 return qe_invalid;
10886
10887 832 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10888 832 }
10889
10890
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
10891 {
10892
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10893 return qe_invalid;
10894
10895
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&flip,f))
10896 return qe_invalid;
10897
10898
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&extend,f))
10899 return qe_invalid;
10900
10901 832 byte frames = 0;
10902
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 812 times.
832 if(v_herosprites > 15)
10903 {
10904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 812 times.
812 if(!p_getc(&frames,f))
10905 return qe_invalid;
10906 812 }
10907
10908 832 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10909 832 liftingspr[q][spr_frames] = frames;
10910 832 }
10911
10912
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
10913 {
10914
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10915 return qe_invalid;
10916
10917
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&flip,f))
10918 return qe_invalid;
10919
10920
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&extend,f))
10921 return qe_invalid;
10922
10923 832 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10924 832 }
10925
10926
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
10927 {
10928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_igetl(&tile,f))
10929 return qe_invalid;
10930
10931
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&flip,f))
10932 return qe_invalid;
10933
10934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
10935 return qe_invalid;
10936
10937 832 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10938 832 }
10939
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
10940 {
10941
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10942 return qe_invalid;
10943
10944
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&flip,f))
10945 return qe_invalid;
10946
10947
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&extend,f))
10948 return qe_invalid;
10949
10950 832 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10951 832 }
10952
10953
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
10954 {
10955
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10956 return qe_invalid;
10957
10958
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&flip,f))
10959 return qe_invalid;
10960
10961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
10962 return qe_invalid;
10963
10964 832 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10965 832 }
10966
10967
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
10968 {
10969
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10970 return qe_invalid;
10971
10972
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&flip,f))
10973 return qe_invalid;
10974
10975
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&extend,f))
10976 return qe_invalid;
10977
10978 832 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10979 832 }
10980
10981
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
10982 {
10983
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10984 return qe_invalid;
10985
10986
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&flip,f))
10987 return qe_invalid;
10988
10989
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&extend,f))
10990 return qe_invalid;
10991
10992 832 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10993 832 }
10994
10995
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
10996 {
10997
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
10998 return qe_invalid;
10999
11000
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&flip,f))
11001 return qe_invalid;
11002
11003
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&extend,f))
11004 return qe_invalid;
11005
11006 832 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11007 832 }
11008
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
11009 {
11010
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
11011 return qe_invalid;
11012
11013
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&flip,f))
11014 return qe_invalid;
11015
11016
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&extend,f))
11017 return qe_invalid;
11018
11019 832 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11020 832 }
11021
11022
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
11023 {
11024
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
11025 return qe_invalid;
11026
11027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
11028 return qe_invalid;
11029
11030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
11031 return qe_invalid;
11032
11033 832 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11034 832 }
11035
11036
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
11037 {
11038
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
11039 return qe_invalid;
11040
11041
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&flip,f))
11042 return qe_invalid;
11043
11044
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&extend,f))
11045 return qe_invalid;
11046
11047 832 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11048 832 }
11049
11050
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
11051 {
11052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_igetl(&tile,f))
11053 return qe_invalid;
11054
11055
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&flip,f))
11056 return qe_invalid;
11057
11058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
11059 return qe_invalid;
11060
11061 832 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11062 832 }
11063
11064
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
11065 {
11066
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
11067 return qe_invalid;
11068
11069
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&flip,f))
11070 return qe_invalid;
11071
11072
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&extend,f))
11073 return qe_invalid;
11074
11075 832 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11076 832 }
11077
11078
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
11079 {
11080
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
11081 return qe_invalid;
11082
11083
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&flip,f))
11084 return qe_invalid;
11085
11086
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&extend,f))
11087 return qe_invalid;
11088
11089 832 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11090 832 }
11091
11092
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
11093 {
11094
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
11095 return qe_invalid;
11096
11097
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&flip,f))
11098 return qe_invalid;
11099
11100
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&extend,f))
11101 return qe_invalid;
11102
11103 832 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11104 832 }
11105
11106
2/2
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 208 times.
832 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
11107 {
11108
1/2
✓ Branch 0 taken 624 times.
✗ Branch 1 not taken.
624 if(!p_igetl(&tile,f))
11109 return qe_invalid;
11110
11111
1/2
✓ Branch 0 taken 624 times.
✗ Branch 1 not taken.
624 if(!p_getc(&flip,f))
11112 return qe_invalid;
11113
11114
1/2
✓ Branch 0 taken 624 times.
✗ Branch 1 not taken.
624 if(!p_getc(&extend,f))
11115 return qe_invalid;
11116
11117 624 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
11118 624 }
11119 208 }
11120 else
11121 {
11122 memset(frozenspr, 0, sizeof(frozenspr));
11123 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
11124 memset(onfirespr, 0, sizeof(onfirespr));
11125 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
11126 memset(diggingspr, 0, sizeof(diggingspr));
11127 memset(usingrodspr, 0, sizeof(usingrodspr));
11128 memset(usingcanespr, 0, sizeof(usingcanespr));
11129 memset(pushingspr, 0, sizeof(pushingspr));
11130 memset(liftingspr, 0, sizeof(liftingspr));
11131 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11132 memset(stunnedspr, 0, sizeof(stunnedspr));
11133 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11134 memset(fallingspr, 0, sizeof(fallingspr));
11135 memset(shockedspr, 0, sizeof(shockedspr));
11136 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11137 memset(pullswordspr, 0, sizeof(pullswordspr));
11138 memset(readingspr, 0, sizeof(readingspr));
11139 memset(slash180spr, 0, sizeof(slash180spr));
11140 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11141 memset(dashspr, 0, sizeof(dashspr));
11142 memset(bonkspr, 0, sizeof(bonkspr));
11143 memset(medallionsprs, 0, sizeof(medallionsprs));
11144 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11145 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11146 for(int32_t q = 0; q < 4; ++q)
11147 {
11148 for(int32_t p = 0; p < 3; ++p)
11149 {
11150 drowningspr[q][p] = divespr[q][p];
11151 drowning_lavaspr[q][p] = divespr[q][p];
11152 }
11153 }
11154 }
11155
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if (v_herosprites > 8)
11156 {
11157
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
11158 {
11159
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
11160 return qe_invalid;
11161
11162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
11163 return qe_invalid;
11164
11165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
11166 return qe_invalid;
11167
11168 832 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11169 832 }
11170 208 }
11171 else
11172 {
11173 memset(sideswimspr, 0, sizeof(sideswimspr));
11174 }
11175
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if (v_herosprites > 9)
11176 {
11177
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
11178 {
11179
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
11180 return qe_invalid;
11181
11182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
11183 return qe_invalid;
11184
11185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
11186 return qe_invalid;
11187
11188 832 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11189 832 }
11190
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
11191 {
11192
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
11193 return qe_invalid;
11194
11195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
11196 return qe_invalid;
11197
11198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
11199 return qe_invalid;
11200
11201 832 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11202 832 }
11203
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
11204 {
11205
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
11206 return qe_invalid;
11207
11208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
11209 return qe_invalid;
11210
11211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
11212 return qe_invalid;
11213
11214 832 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11215 832 }
11216
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
11217 {
11218
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
11219 return qe_invalid;
11220
11221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
11222 return qe_invalid;
11223
11224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
11225 return qe_invalid;
11226
11227 832 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11228 832 }
11229 208 }
11230 else
11231 {
11232 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11233 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11234 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11235 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11236 }
11237
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if (v_herosprites > 10)
11238 {
11239
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
11240 {
11241 int32_t hmr;
11242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_igetl(&hmr,f))
11243 return qe_invalid;
11244
11245 832 hammeroffsets[q] = hmr;
11246 832 }
11247 208 }
11248 else
11249 {
11250 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11251 }
11252
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if (v_herosprites > 11)
11253 {
11254
2/2
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 208 times.
832 for(int32_t q = 0; q < 3; ++q)
11255 {
11256
1/2
✓ Branch 0 taken 624 times.
✗ Branch 1 not taken.
624 if(!p_igetl(&tile,f))
11257 return qe_invalid;
11258
11259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 624 times.
624 if(!p_getc(&flip,f))
11260 return qe_invalid;
11261
11262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 624 times.
624 if(!p_getc(&extend,f))
11263 return qe_invalid;
11264
11265 624 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11266 624 }
11267 208 }
11268 else
11269 {
11270 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11271 }
11272
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if (v_herosprites > 12)
11273 {
11274
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if(!p_igetl(&tile,f))
11275 return qe_invalid;
11276
11277
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if(!p_getc(&flip,f))
11278 return qe_invalid;
11279
11280
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if(!p_getc(&extend,f))
11281 return qe_invalid;
11282 208 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11283
11284 208 }
11285 else
11286 {
11287 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11288 }
11289
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if (v_herosprites > 13)
11290 {
11291
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
11292 {
11293
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
11294 return qe_invalid;
11295
11296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
11297 return qe_invalid;
11298
11299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
11300 return qe_invalid;
11301
11302 832 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11303 832 }
11304 208 }
11305 else
11306 {
11307 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11308 }
11309
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if (v_herosprites > 14)
11310 {
11311
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 208 times.
1040 for(int32_t q = 0; q < 4; ++q)
11312 {
11313
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_igetl(&tile,f))
11314 return qe_invalid;
11315
11316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&flip,f))
11317 return qe_invalid;
11318
11319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if(!p_getc(&extend,f))
11320 return qe_invalid;
11321
11322 832 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11323 832 }
11324 208 }
11325 else
11326 {
11327 memset(revslashspr, 0, sizeof(revslashspr));
11328 }
11329
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if (v_herosprites > 7)
11330 {
11331 208 int32_t num_defense = wMax;
11332 208 byte def = 0;
11333
11334 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11335 /*if(v_herosprites > [x])
11336 * {
11337 * num_defense = 146 //value of wMax on version 8
11338 * }
11339 */
11340
11341
2/2
✓ Branch 0 taken 30368 times.
✓ Branch 1 taken 208 times.
30576 for (int32_t q = 0; q < num_defense; q++)
11342 {
11343
1/2
✓ Branch 0 taken 30368 times.
✗ Branch 1 not taken.
30368 if (!p_getc(&def, f))
11344 return qe_invalid;
11345
11346 30368 hero_defenses[q] = def;
11347 30368 }
11348 208 }
11349 else
11350 {
11351 int32_t num_defense = wMax;
11352 for (int32_t q = 0; q < num_defense; q++)
11353 {
11354 hero_defenses[q] = 0;
11355 }
11356 }
11357 208 }
11358
11359
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 11 times.
208 if(FFCore.quest_format[vInitData] < 34)
11360 {
11361 11 bool fastswim = zinit.hero_swim_speed > 60;
11362 // '2/3' or '1/2'
11363 11 zinit.hero_swim_mult = fastswim ? 2 : 1;
11364 11 zinit.hero_swim_div = fastswim ? 3 : 2;
11365 11 }
11366 208 return 0;
11367 208 }
11368
11369
11370 408 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11371 {
11372 //these are here to bypass compiler warnings about unused arguments
11373 408 Header=Header;
11374
11375 dword dummy;
11376 408 word s_version=0;
11377
11378 //section version info
11379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(!p_igetw(&s_version,f))
11380 {
11381 return qe_invalid;
11382 }
11383
11384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if (s_version > V_HEROSPRITES)
11385 return qe_version;
11386
11387 408 FFCore.quest_format[vHeroSprites] = s_version;
11388
11389
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!read_deprecated_section_cversion(f))
11390 {
11391 return qe_invalid;
11392 }
11393
11394 //section size
11395
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_igetl(&dummy,f))
11396 {
11397 return qe_invalid;
11398 }
11399
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 200 times.
408 if ( s_version >= 6 )
11400 {
11401 208 return readherosprites3(f, s_version);
11402 }
11403 200 else return readherosprites2(f, s_version);
11404 408 }
11405
11406 217 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11407 {
11408 217 subscreens_active.clear();
11409 217 subscreens_passive.clear();
11410 217 subscreens_overlay.clear();
11411
2/2
✓ Branch 0 taken 27776 times.
✓ Branch 1 taken 217 times.
27993 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11412 {
11413 subscreen_group g;
11414 27776 memset(&g,0,sizeof(subscreen_group));
11415 27776 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(ret!=0)
11417 return ret;
11418
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 26659 times.
27776 if(g.objects[0].type == ssoNULL) continue;
11419
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 650 times.
1117 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11420 1117 ZCSubscreen& sub = vec.emplace_back();
11421 1117 sub.load_old(g);
11422 1117 }
11423
11424 217 return 0;
11425 217 }
11426
11427 27776 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11428 {
11429 27776 int32_t numsub=0;
11430 27776 byte temp_ss=0;
11431 subscreen_object temp_sub_stack;
11432 27776 subscreen_object *temp_sub = &temp_sub_stack;
11433
11434 char tempname[64];
11435
11436 // FWIW I never saw anything bigger than 20.
11437 #define MAX_DP1_LEN 1024
11438 char tempdp1[MAX_DP1_LEN];
11439
11440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(!pfread(tempname,64,f))
11441 {
11442 return qe_invalid;
11443 }
11444
11445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(s_version > 1)
11446 {
11447
1/2
✓ Branch 0 taken 27776 times.
✗ Branch 1 not taken.
27776 if(!p_getc(&temp_ss,f))
11448 {
11449 return qe_invalid;
11450 }
11451 27776 }
11452
11453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27776 times.
27776 if(s_version < 4)
11454 {
11455 uint8_t tmp=0;
11456
11457 if(!p_getc(&tmp,f))
11458 {
11459 return qe_invalid;
11460 }
11461
11462 numsub = (int32_t)tmp;
11463 }
11464 else
11465 {
11466 word tmp;
11467
11468
1/2
✓ Branch 0 taken 27776 times.
✗ Branch 1 not taken.
27776 if(!p_igetw(&tmp, f))
11469 {
11470 return qe_invalid;
11471 }
11472
11473 27776 numsub = (int32_t)tmp;
11474 }
11475
11476 int32_t j;
11477
11478
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 71950 times.
✓ Branch 2 taken 44174 times.
✓ Branch 3 taken 27776 times.
71950 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11479 {
11480 44174 memset(temp_sub,0,sizeof(subscreen_object));
11481
11482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44174 times.
44174 switch(g->objects[j].type)
11483 {
11484 case ssoTEXT:
11485 case ssoTEXTBOX:
11486 case ssoCURRENTITEMTEXT:
11487 case ssoCURRENTITEMCLASSTEXT:
11488 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11489
11490 //fall through
11491 default:
11492 44174 memset(&g->objects[j],0,sizeof(subscreen_object));
11493 44174 break;
11494 }
11495
11496
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->type),f))
11497 return qe_invalid;
11498
11499
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->pos),f))
11500 return qe_invalid;
11501
11502
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(s_version < 5)
11503 {
11504 switch(temp_sub->pos)
11505 {
11506 case 0:
11507 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11508 break;
11509
11510 case 1:
11511 temp_sub->pos = sspUP;
11512 break;
11513
11514 case 2:
11515 temp_sub->pos = sspDOWN;
11516 break;
11517
11518 default:
11519 temp_sub->pos = 0;
11520 }
11521 }
11522
11523
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->x),f))
11524 return qe_invalid;
11525
11526
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->y),f))
11527 return qe_invalid;
11528
11529
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->w),f))
11530 return qe_invalid;
11531
11532
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->h),f))
11533 return qe_invalid;
11534
11535
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->colortype1),f))
11536 return qe_invalid;
11537
11538
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->color1),f))
11539 return qe_invalid;
11540
11541
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->colortype2),f))
11542 return qe_invalid;
11543
11544
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->color2),f))
11545 return qe_invalid;
11546
11547
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->colortype3),f))
11548 return qe_invalid;
11549
11550
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->color3),f))
11551 return qe_invalid;
11552
11553
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d1),f))
11554 return qe_invalid;
11555
11556
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d2),f))
11557 return qe_invalid;
11558
11559
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d3),f))
11560 return qe_invalid;
11561
11562
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d4),f))
11563 return qe_invalid;
11564
11565
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d5),f))
11566 return qe_invalid;
11567
11568
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d6),f))
11569 return qe_invalid;
11570
11571
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d7),f))
11572 return qe_invalid;
11573
11574
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d8),f))
11575 return qe_invalid;
11576
11577
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d9),f))
11578 return qe_invalid;
11579
11580
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetd(&(temp_sub->d10),f))
11581 return qe_invalid;
11582
11583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44174 times.
44174 if(s_version < 2)
11584 {
11585 if(!p_igetl(&(temp_sub->speed),f))
11586 return qe_invalid;
11587
11588 if(!p_igetl(&(temp_sub->delay),f))
11589 return qe_invalid;
11590
11591 if(!p_igetl(&(temp_sub->frame),f))
11592 return qe_invalid;
11593 }
11594 else
11595 {
11596
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->speed),f))
11597 return qe_invalid;
11598
11599
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_getc(&(temp_sub->delay),f))
11600 return qe_invalid;
11601
11602
1/2
✓ Branch 0 taken 44174 times.
✗ Branch 1 not taken.
44174 if(!p_igetw(&(temp_sub->frame),f))
11603 return qe_invalid;
11604 }
11605
11606 44174 int32_t temp_size=0;
11607
11608 // bool deletets = false;
11609
4/4
✓ Branch 0 taken 19541 times.
✓ Branch 1 taken 3389 times.
✓ Branch 2 taken 21002 times.
✓ Branch 3 taken 242 times.
44174 switch(temp_sub->type)
11610 {
11611 case ssoTEXT:
11612 case ssoTEXTBOX:
11613 case ssoCURRENTITEMTEXT:
11614 case ssoCURRENTITEMCLASSTEXT:
11615 {
11616 word temptempsize;
11617
11618
1/2
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
3389 if(!p_igetw(&temptempsize,f))
11619 {
11620 return qe_invalid;
11621 }
11622
11623 //temptempsize = temp1 + (temp2 << 8);
11624 3389 temp_size = (int32_t)temptempsize;
11625 3389 uint32_t char_length = temp_size+2;
11626
1/2
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
3389 if (char_length > MAX_DP1_LEN)
11627 {
11628 return qe_invalid;
11629 }
11630 3389 tempdp1[char_length - 1] = '\0';
11631
11632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3389 times.
3389 if(temp_size)
11633
1/2
✓ Branch 0 taken 3389 times.
✗ Branch 1 not taken.
3389 if(!pfread(tempdp1,temp_size+1,f))
11634 return qe_invalid;
11635 3389 break;
11636 }
11637
11638 case ssoLIFEMETER:
11639
1/2
✓ Branch 0 taken 242 times.
✗ Branch 1 not taken.
242 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11640 temp_sub->d3 = 1;
11641
11642
1/2
✓ Branch 0 taken 242 times.
✗ Branch 1 not taken.
242 if(!p_getc(&(temp_sub->dp1),f))
11643 return qe_invalid;
11644
11645 242 break;
11646
11647
11648 case ssoCURRENTITEM:
11649
11650
1/2
✓ Branch 0 taken 19541 times.
✗ Branch 1 not taken.
19541 if(s_version < 6)
11651 {
11652 switch(temp_sub->d1)
11653 {
11654 case ssiBOMB:
11655 temp_sub->d1 = itype_bomb;
11656 break;
11657
11658 case ssiSWORD:
11659 temp_sub->d1 = itype_sword;
11660 break;
11661
11662 case ssiSHIELD:
11663 temp_sub->d1 = itype_shield;
11664 break;
11665
11666 case ssiCANDLE:
11667 temp_sub->d1 = itype_candle;
11668 break;
11669
11670 case ssiLETTER:
11671 temp_sub->d1 = itype_letter;
11672 break;
11673
11674 case ssiPOTION:
11675 temp_sub->d1 = itype_potion;
11676 break;
11677
11678 case ssiLETTERPOTION:
11679 temp_sub->d1 = itype_letterpotion;
11680 break;
11681
11682 case ssiBOW:
11683 temp_sub->d1 = itype_bow;
11684 break;
11685
11686 case ssiARROW:
11687 temp_sub->d1 = itype_arrow;
11688 break;
11689
11690 case ssiBOWANDARROW:
11691 temp_sub->d1 = itype_bowandarrow;
11692 break;
11693
11694 case ssiBAIT:
11695 temp_sub->d1 = itype_bait;
11696 break;
11697
11698 case ssiRING:
11699 temp_sub->d1 = itype_ring;
11700 break;
11701
11702 case ssiBRACELET:
11703 temp_sub->d1 = itype_bracelet;
11704 break;
11705
11706 case ssiMAP:
11707 temp_sub->d1 = itype_map;
11708 break;
11709
11710 case ssiCOMPASS:
11711 temp_sub->d1 = itype_compass;
11712 break;
11713
11714 case ssiBOSSKEY:
11715 temp_sub->d1 = itype_bosskey;
11716 break;
11717
11718 case ssiMAGICKEY:
11719 temp_sub->d1 = itype_magickey;
11720 break;
11721
11722 case ssiBRANG:
11723 temp_sub->d1 = itype_brang;
11724 break;
11725
11726 case ssiWAND:
11727 temp_sub->d1 = itype_wand;
11728 break;
11729
11730 case ssiRAFT:
11731 temp_sub->d1 = itype_raft;
11732 break;
11733
11734 case ssiLADDER:
11735 temp_sub->d1 = itype_ladder;
11736 break;
11737
11738 case ssiWHISTLE:
11739 temp_sub->d1 = itype_whistle;
11740 break;
11741
11742 case ssiBOOK:
11743 temp_sub->d1 = itype_book;
11744 break;
11745
11746 case ssiWALLET:
11747 temp_sub->d1 = itype_wallet;
11748 break;
11749
11750 case ssiSBOMB:
11751 temp_sub->d1 = itype_sbomb;
11752 break;
11753
11754 case ssiHCPIECE:
11755 temp_sub->d1 = itype_heartpiece;
11756 break;
11757
11758 case ssiAMULET:
11759 temp_sub->d1 = itype_amulet;
11760 break;
11761
11762 case ssiFLIPPERS:
11763 temp_sub->d1 = itype_flippers;
11764 break;
11765
11766 case ssiHOOKSHOT:
11767 temp_sub->d1 = itype_hookshot;
11768 break;
11769
11770 case ssiLENS:
11771 temp_sub->d1 = itype_lens;
11772 break;
11773
11774 case ssiHAMMER:
11775 temp_sub->d1 = itype_hammer;
11776 break;
11777
11778 case ssiBOOTS:
11779 temp_sub->d1 = itype_boots;
11780 break;
11781
11782 case ssiDIVINEFIRE:
11783 temp_sub->d1 = itype_divinefire;
11784 break;
11785
11786 case ssiDIVINEESCAPE:
11787 temp_sub->d1 = itype_divineescape;
11788 break;
11789
11790 case ssiDIVINEPROTECTION:
11791 temp_sub->d1 = itype_divineprotection;
11792 break;
11793
11794 case ssiQUIVER:
11795 temp_sub->d1 = itype_quiver;
11796 break;
11797
11798 case ssiBOMBBAG:
11799 temp_sub->d1 = itype_bombbag;
11800 break;
11801
11802 case ssiCBYRNA:
11803 temp_sub->d1 = itype_cbyrna;
11804 break;
11805
11806 case ssiROCS:
11807 temp_sub->d1 = itype_rocs;
11808 break;
11809
11810 case ssiHOVERBOOTS:
11811 temp_sub->d1 = itype_hoverboots;
11812 break;
11813
11814 case ssiSPINSCROLL:
11815 temp_sub->d1 = itype_spinscroll;
11816 break;
11817
11818 case ssiCROSSSCROLL:
11819 temp_sub->d1 = itype_crossscroll;
11820 break;
11821
11822 case ssiQUAKESCROLL:
11823 temp_sub->d1 = itype_quakescroll;
11824 break;
11825
11826 case ssiWHISPRING:
11827 temp_sub->d1 = itype_whispring;
11828 break;
11829
11830 case ssiCHARGERING:
11831 temp_sub->d1 = itype_chargering;
11832 break;
11833
11834 case ssiPERILSCROLL:
11835 temp_sub->d1 = itype_perilscroll;
11836 break;
11837
11838 case ssiWEALTHMEDAL:
11839 temp_sub->d1 = itype_wealthmedal;
11840 break;
11841
11842 case ssiHEARTRING:
11843 temp_sub->d1 = itype_heartring;
11844 break;
11845
11846 case ssiMAGICRING:
11847 temp_sub->d1 = itype_magicring;
11848 break;
11849
11850 case ssiSPINSCROLL2:
11851 temp_sub->d1 = itype_spinscroll2;
11852 break;
11853
11854 case ssiQUAKESCROLL2:
11855 temp_sub->d1 = itype_quakescroll2;
11856 break;
11857
11858 case ssiAGONY:
11859 temp_sub->d1 = itype_agony;
11860 break;
11861
11862 case ssiSTOMPBOOTS:
11863 temp_sub->d1 = itype_stompboots;
11864 break;
11865
11866 case ssiWHIMSICALRING:
11867 temp_sub->d1 = itype_whimsicalring;
11868 break;
11869
11870 case ssiPERILRING:
11871 temp_sub->d1 = itype_perilring;
11872 break;
11873
11874 default:
11875 temp_sub->d1 += itype_custom1 - ssiMAX;
11876 }
11877 }
11878
11879 //fall-through
11880 default:
11881
1/2
✓ Branch 0 taken 40543 times.
✗ Branch 1 not taken.
40543 if(!p_getc(&(temp_sub->dp1),f))
11882 return qe_invalid;
11883
11884 40543 break;
11885 }
11886
11887
2/2
✓ Branch 0 taken 8694 times.
✓ Branch 1 taken 35480 times.
44174 if(s_version < 7)
11888 {
11889
3/3
✓ Branch 0 taken 29642 times.
✓ Branch 1 taken 1270 times.
✓ Branch 2 taken 4568 times.
35480 switch(temp_sub->type)
11890 {
11891 case ssoMAGICGAUGE:
11892 {
11893
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 1136 times.
1270 if(!temp_sub->d9)
11894 1136 temp_sub->d9 = -1; //-1 now represents 'always'
11895 1270 break;
11896 }
11897 case ssoLIFEGAUGE:
11898 4568 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11899 4568 break;
11900 }
11901 35480 }
11902
11903
3/3
✓ Branch 0 taken 3389 times.
✓ Branch 1 taken 39307 times.
✓ Branch 2 taken 1478 times.
44174 switch(temp_sub->type)
11904 {
11905 case ssoTEXT:
11906 case ssoTEXTBOX:
11907 case ssoCURRENTITEMTEXT:
11908 case ssoCURRENTITEMCLASSTEXT:
11909
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3389 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3389 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
11910
11911 3389 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11912 3389 g->objects[j].dp1 = new char[temp_size+2];
11913 3389 strcpy((char*)g->objects[j].dp1,tempdp1);
11914 3389 break;
11915
11916 case ssoCOUNTER:
11917
1/2
✓ Branch 0 taken 1478 times.
✗ Branch 1 not taken.
1478 if(s_version<3)
11918 {
11919 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11920 temp_sub->d8=0;
11921 }
11922
11923 default:
11924 40785 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11925 40785 break;
11926 }
11927
11928 44174 g->name[0] = '\0';
11929 44174 strncat(g->name, tempname, 64 - 1);
11930 44174 g->ss_type = temp_ss;
11931 44174 }
11932
11933
2/2
✓ Branch 0 taken 7066482 times.
✓ Branch 1 taken 27776 times.
7094258 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11934 {
11935 //clear all unused object in this subscreen -DD
11936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7066482 times.
7066482 switch(g->objects[j].type)
11937 {
11938 case ssoTEXT:
11939 case ssoTEXTBOX:
11940 case ssoCURRENTITEMTEXT:
11941 case ssoCURRENTITEMCLASSTEXT:
11942 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11943
11944 //fall through
11945 default:
11946 7066482 memset(&g->objects[j],0,sizeof(subscreen_object));
11947 7066482 break;
11948 }
11949 7066482 }
11950
11951 27776 return 0;
11952 27776 }
11953
11954 408 int32_t readsubscreens(PACKFILE *f)
11955 {
11956 word s_version;
11957 dword dummy;
11958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(!p_igetw(&s_version,f))
11959 return qe_invalid;
11960
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if (s_version > V_SUBSCREEN)
11961 return qe_version;
11962 408 FFCore.quest_format[vSubscreen] = s_version;
11963
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!read_deprecated_section_cversion(f))
11964 return qe_invalid;
11965
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_igetl(&dummy,f)) //section size
11966 return qe_invalid;
11967
11968
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 191 times.
408 if(s_version < 8)
11969 217 return read_old_subscreens(f,s_version);
11970
11971 191 subscreens_active.clear();
11972 191 subscreens_passive.clear();
11973 191 subscreens_overlay.clear();
11974
11975 byte sz;
11976
1/2
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
191 if(!p_getc(&sz,f))
11977 return qe_invalid;
11978
2/2
✓ Branch 0 taken 599 times.
✓ Branch 1 taken 191 times.
790 for(byte q = 0; q < sz; ++q)
11979 {
11980 599 ZCSubscreen& tmp = subscreens_active.emplace_back();
11981
1/2
✓ Branch 0 taken 599 times.
✗ Branch 1 not taken.
599 if (auto ret = tmp.read(f, s_version))
11982 return ret;
11983 599 }
11984
1/2
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
191 if(!p_getc(&sz,f))
11985 return qe_invalid;
11986
2/2
✓ Branch 0 taken 722 times.
✓ Branch 1 taken 191 times.
913 for(byte q = 0; q < sz; ++q)
11987 {
11988 722 ZCSubscreen& tmp = subscreens_passive.emplace_back();
11989
1/2
✓ Branch 0 taken 722 times.
✗ Branch 1 not taken.
722 if (auto ret = tmp.read(f, s_version))
11990 return ret;
11991 722 }
11992
1/2
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
191 if(!p_getc(&sz,f))
11993 return qe_invalid;
11994
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 191 times.
201 for(byte q = 0; q < sz; ++q)
11995 {
11996 10 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
11997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (auto ret = tmp.read(f, s_version))
11998 return ret;
11999 10 }
12000 191 return 0;
12001 408 }
12002
12003 void reset_subscreen(subscreen_group *tempss)
12004 {
12005 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
12006 {
12007 switch(tempss->objects[i].type)
12008 {
12009 case ssoTEXT:
12010 case ssoTEXTBOX:
12011 case ssoCURRENTITEMTEXT:
12012 case ssoCURRENTITEMCLASSTEXT:
12013 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
12014
12015 //fall through
12016 default:
12017 memset(&tempss->objects[i],0,sizeof(subscreen_object));
12018 break;
12019 }
12020 }
12021 }
12022
12023 117 void reset_subscreens()
12024 {
12025 117 subscreens_active.clear();
12026 117 subscreens_passive.clear();
12027 117 subscreens_overlay.clear();
12028 117 }
12029
12030 117 int32_t setupsubscreens()
12031 {
12032 117 reset_subscreens();
12033 //return 0;
12034
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 234 times.
351 for(int q = 0; q < 2; ++q)
12035 {
12036 234 subscreens_active.emplace_back();
12037 234 subscreens_passive.emplace_back();
12038 234 }
12039 117 int32_t tempsubscreen=subscr_mode;
12040
12041
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if(tempsubscreen>=ssdtMAX)
12042 tempsubscreen=0;
12043
12044
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
✗ Branch 2 not taken.
117 switch(tempsubscreen)
12045 {
12046 case ssdtOLD:
12047 case ssdtNEWSUBSCR:
12048 case ssdtREV2:
12049 case ssdtBSZELDA:
12050 case ssdtBSZELDAMODIFIED:
12051 case ssdtBSZELDAENHANCED:
12052 case ssdtBSZELDACOMPLETE:
12053 {
12054 117 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
12055 117 subscreens_active[0].sub_type=sstACTIVE;
12056 117 subscreens_active[0].name = "Active Subscreen (Triforce)";
12057 117 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
12058 117 subscreens_active[1].sub_type=sstACTIVE;
12059 117 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
12060 117 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
12061 117 subscreens_passive[0].sub_type=sstPASSIVE;
12062 117 subscreens_passive[0].name = "Passive Subscreen (Magic)";
12063 117 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
12064 117 subscreens_passive[1].sub_type=sstPASSIVE;
12065 117 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
12066 117 break;
12067 }
12068
12069 case ssdtZ3:
12070 {
12071 subscreens_active[0].load_old(z3_active_a);
12072 subscreens_active[0].sub_type=sstACTIVE;
12073 subscreens_active[1].load_old(z3_active_ab);
12074 subscreens_active[1].sub_type=sstACTIVE;
12075 subscreens_passive[0].load_old(z3_passive_a);
12076 subscreens_passive[0].sub_type=sstPASSIVE;
12077 subscreens_passive[1].load_old(z3_passive_ab);
12078 subscreens_passive[1].sub_type=sstPASSIVE;
12079 break;
12080 }
12081 }
12082 117 subscr_mode = ssdtMAX;
12083 117 return 0;
12084 }
12085
12086 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
12087
12088 extern script_data *ffscripts[NUMSCRIPTFFC];
12089 extern script_data *itemscripts[NUMSCRIPTITEM];
12090 extern script_data *guyscripts[NUMSCRIPTGUYS];
12091 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12092 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12093 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12094 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12095 extern script_data *playerscripts[NUMSCRIPTHERO];
12096 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12097 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12098 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12099 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12100 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
12101
12102 static std::vector<const script_data*> read_scripts;
12103
12104 437 static script_data fake_script_data(ScriptType::None, 0);
12105
12106 486 int32_t readffscript(PACKFILE *f, zquestheader *Header)
12107 {
12108 int32_t dummy;
12109 486 word s_version=0, zmeta_version=0;
12110 486 byte numscripts=0;
12111 486 numscripts=numscripts; //to avoid unused variables warnings
12112 int32_t ret;
12113 486 read_scripts.clear();
12114 486 zasm_scripts.clear();
12115
12116 //section version info
12117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 486 times.
486 if(!p_igetw(&s_version,f))
12118 {
12119 return qe_invalid;
12120 }
12121
12122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 486 times.
486 if (s_version > V_FFSCRIPT)
12123 return qe_version;
12124
12125 486 FFCore.quest_format[vFFScript] = s_version;
12126
12127
1/2
✓ Branch 0 taken 486 times.
✗ Branch 1 not taken.
486 if(!read_deprecated_section_cversion(f))
12128 {
12129 return qe_invalid;
12130 }
12131
12132
2/2
✓ Branch 0 taken 278 times.
✓ Branch 1 taken 208 times.
486 if(s_version >= 18)
12133 {
12134
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if(!p_igetw(&zmeta_version,f))
12135 {
12136 return qe_invalid;
12137 }
12138 208 }
12139
12140 //section size
12141
1/2
✓ Branch 0 taken 486 times.
✗ Branch 1 not taken.
486 if(!p_igetl(&dummy,f))
12142 {
12143 return qe_invalid;
12144 }
12145
12146
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 219 times.
486 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12147 486 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12148
12149
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 142 times.
486 if(s_version >= 27)
12150 {
12151 142 ret = read_quest_zasm(f, s_version);
12152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if(ret)
12153 return qe_invalid;
12154 142 }
12155
12156 //finally... section data
12157
2/2
✓ Branch 0 taken 208896 times.
✓ Branch 1 taken 424 times.
209320 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12158 {
12159 208896 ret = read_one_ffscript(f, Header, i, s_version, ffscripts[i], zmeta_version);
12160
12161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208896 times.
208896 if (ret)
12162 {
12163 return qe_invalid;
12164 }
12165 208896 }
12166
12167 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12168 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12169 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12170 * there was a version bump a week before a change that broke stuff.
12171 */
12172
7/8
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 216 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 208 times.
✓ Branch 4 taken 208 times.
✓ Branch 5 taken 208 times.
✓ Branch 6 taken 208 times.
✓ Branch 7 taken 208 times.
424 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
12173 {
12174 632 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
12175 632 }
12176
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 200 times.
408 if(s_version < 19)
12177 {
12178 200 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
12179 200 }
12180
12181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(s_version > 1)
12182 {
12183
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 408 times.
104856 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12184 {
12185 104448 ret = read_one_ffscript(f, Header, i, s_version, itemscripts[i], zmeta_version);
12186
12187
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if (ret)
12188 {
12189 return qe_invalid;
12190 }
12191 104448 }
12192
12193
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 408 times.
104856 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12194 {
12195 104448 ret = read_one_ffscript(f, Header, i, s_version, guyscripts[i], zmeta_version);
12196
12197
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if (ret)
12198 {
12199 return qe_invalid;
12200 }
12201 104448 }
12202
12203
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 408 times.
104856 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12204 {
12205 104448 ret = read_one_ffscript(f, Header, i, s_version, &fake_script_data, zmeta_version);
12206
12207
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if (ret)
12208 {
12209 return qe_invalid;
12210 }
12211 104448 }
12212
12213
2/2
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 408 times.
104856 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12214 {
12215 104448 ret = read_one_ffscript(f, Header, i, s_version, screenscripts[i], zmeta_version);
12216
12217
1/2
✓ Branch 0 taken 104448 times.
✗ Branch 1 not taken.
104448 if (ret)
12218 {
12219 return qe_invalid;
12220 }
12221 104448 }
12222
12223
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 200 times.
408 if(s_version > 16)
12224 {
12225
2/2
✓ Branch 0 taken 1664 times.
✓ Branch 1 taken 208 times.
1872 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12226 {
12227 1664 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12228
12229
1/2
✓ Branch 0 taken 1664 times.
✗ Branch 1 not taken.
1664 if (ret)
12230 {
12231 return qe_invalid;
12232 }
12233 1664 }
12234 208 }
12235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 else if(s_version > 13)
12236 {
12237 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12238 {
12239 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12240
12241 if (ret)
12242 {
12243 return qe_invalid;
12244 }
12245 }
12246
12247 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12248 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12249
12250 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12251 }
12252
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 else if(s_version > 4)
12253 {
12254
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 200 times.
1000 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12255 {
12256 800 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12257
12258
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if (ret)
12259 {
12260 return qe_invalid;
12261 }
12262 800 }
12263
12264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12265
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12266
12267
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12268
12269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12270
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12271
12272
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12273
12274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12275
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_F6];
12276
12277
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12278
12279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12280
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12281
12282
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12283 200 }
12284 else
12285 {
12286 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12287 {
12288 ret = read_one_ffscript(f, Header, i, s_version, globalscripts[i], zmeta_version);
12289
12290 if (ret)
12291 {
12292 return qe_invalid;
12293 }
12294 }
12295
12296 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12297 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12298
12299 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVELOAD);
12300
12301 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12302 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12303
12304 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12305
12306 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12307 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12308
12309 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12310
12311 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12312 delete globalscripts[GLOBAL_SCRIPT_F6];
12313
12314 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12315
12316 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12317 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12318
12319 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12320 }
12321
12322
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 200 times.
408 if(s_version > 10) //expanded the number of Hero scripts to 5.
12323 {
12324
2/2
✓ Branch 0 taken 1040 times.
✓ Branch 1 taken 208 times.
1248 for(int32_t i = 0; i < NUMSCRIPTHERO; i++)
12325 {
12326 1040 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12327
12328
1/2
✓ Branch 0 taken 1040 times.
✗ Branch 1 not taken.
1040 if (ret)
12329 {
12330 return qe_invalid;
12331 }
12332 1040 }
12333 208 }
12334 else
12335 {
12336
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 200 times.
800 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12337 {
12338 600 ret = read_one_ffscript(f, Header, i, s_version, playerscripts[i], zmeta_version);
12339
12340
1/2
✓ Branch 0 taken 600 times.
✗ Branch 1 not taken.
600 if (ret)
12341 {
12342 return qe_invalid;
12343 }
12344 600 }
12345
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(playerscripts[3] != NULL)
12346
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 delete playerscripts[3];
12347
12348
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 playerscripts[3] = new script_data(ScriptType::Hero, 3);
12349
12350
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(playerscripts[4] != NULL)
12351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 delete playerscripts[4];
12352
12353
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 playerscripts[4] = new script_data(ScriptType::Hero, 4);
12354 }
12355
3/4
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 200 times.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
408 if(s_version > 8 && s_version < 10)
12356 {
12357
12358 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12359 {
12360 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12361
12362 if (ret)
12363 {
12364 return qe_invalid;
12365 }
12366 }
12367 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12368 {
12369 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12370
12371 if (ret)
12372 {
12373 return qe_invalid;
12374 }
12375 }
12376
12377 }
12378
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 208 times.
408 if(s_version >= 10)
12379 {
12380
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 208 times.
53456 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12381 {
12382 53248 ret = read_one_ffscript(f, Header, i, s_version, lwpnscripts[i], zmeta_version);
12383
12384
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if (ret)
12385 {
12386 return qe_invalid;
12387 }
12388 53248 }
12389
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 208 times.
53456 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12390 {
12391 53248 ret = read_one_ffscript(f, Header, i, s_version, ewpnscripts[i], zmeta_version);
12392
12393
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if (ret)
12394 {
12395 return qe_invalid;
12396 }
12397 53248 }
12398
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 208 times.
53456 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12399 {
12400 53248 ret = read_one_ffscript(f, Header, i, s_version, dmapscripts[i], zmeta_version);
12401
12402
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if (ret)
12403 {
12404 return qe_invalid;
12405 }
12406 53248 }
12407
12408 208 }
12409
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 208 times.
408 if(s_version >=12)
12410 {
12411
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 208 times.
53456 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12412 {
12413 53248 ret = read_one_ffscript(f, Header, i, s_version, itemspritescripts[i], zmeta_version);
12414
12415
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 if (ret)
12416 {
12417 return qe_invalid;
12418 }
12419 53248 }
12420 208 }
12421
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 208 times.
408 if(s_version >=15)
12422 {
12423
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 208 times.
106704 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12424 {
12425 106496 ret = read_one_ffscript(f, Header, i, s_version, comboscripts[i], zmeta_version);
12426
12427
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if (ret)
12428 {
12429 return qe_invalid;
12430 }
12431 106496 }
12432 208 }
12433
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 208 times.
408 if(s_version >19)
12434 {
12435 208 word numgenscripts = NUMSCRIPTSGENERIC;
12436
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if(!p_igetw(&numgenscripts,f))
12437 {
12438 return qe_invalid;
12439 }
12440
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 208 times.
106704 for(int32_t i = 0; i < numgenscripts; i++)
12441 {
12442 106496 ret = read_one_ffscript(f, Header, i, s_version, genericscripts[i], zmeta_version);
12443
12444
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if (ret)
12445 {
12446 return qe_invalid;
12447 }
12448 106496 }
12449 208 }
12450
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 191 times.
408 if(s_version >21)
12451 {
12452 191 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12453
1/2
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
191 if(!p_igetw(&numsubscripts,f))
12454 {
12455 return qe_invalid;
12456 }
12457
2/2
✓ Branch 0 taken 48896 times.
✓ Branch 1 taken 191 times.
49087 for(int32_t i = 0; i < numsubscripts; i++)
12458 {
12459 48896 ret = read_one_ffscript(f, Header, i, s_version, subscreenscripts[i], zmeta_version);
12460
12461
1/2
✓ Branch 0 taken 48896 times.
✗ Branch 1 not taken.
48896 if (ret)
12462 {
12463 return qe_invalid;
12464 }
12465 48896 }
12466 191 }
12467 408 }
12468
12469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(s_version > 2)
12470 {
12471 int32_t bufsize;
12472 408 p_igetl(&bufsize, f);
12473
2/4
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 408 times.
408 if (bufsize < 0 || bufsize > 1024*1024*10)
12474 {
12475 // God help anyone storing more than 10MB of code in the script buffer.
12476 return qe_invalid;
12477 }
12478 408 char * buf = new char[bufsize+1];
12479 408 pfread(buf, bufsize, f);
12480 408 buf[bufsize]=0;
12481
12482
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 zScript = string(buf);
12483
12484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 delete[] buf;
12485 word numffcbindings;
12486 408 p_igetw(&numffcbindings, f);
12487
12488
2/2
✓ Branch 0 taken 11753 times.
✓ Branch 1 taken 408 times.
12161 for(int32_t i=0; i<numffcbindings; i++)
12489 {
12490 word id;
12491 11753 p_igetw(&id, f);
12492 11753 p_igetl(&bufsize, f);
12493
2/4
✓ Branch 0 taken 11753 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11753 times.
11753 if (bufsize < 0 || bufsize > 1024)
12494 return qe_invalid;
12495 11753 buf = new char[bufsize+1];
12496 11753 pfread(buf, bufsize, f);
12497 11753 buf[bufsize]=0;
12498
12499 //fix for buggy older saved quests -DD
12500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11753 times.
11753 if(id < NUMSCRIPTFFC-1)
12501 11753 ffcmap[id].scriptname = buf;
12502
12503
1/2
✓ Branch 0 taken 11753 times.
✗ Branch 1 not taken.
11753 delete[] buf;
12504 11753 }
12505
12506 word numglobalbindings;
12507 408 p_igetw(&numglobalbindings, f);
12508
12509
2/2
✓ Branch 0 taken 1659 times.
✓ Branch 1 taken 408 times.
2067 for(int32_t i=0; i<numglobalbindings; i++)
12510 {
12511 word id;
12512 1659 p_igetw(&id, f);
12513 1659 p_igetl(&bufsize, f);
12514
2/4
✓ Branch 0 taken 1659 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1659 times.
✗ Branch 3 not taken.
1659 if (bufsize < 0 || bufsize > 1024)
12515 return qe_invalid;
12516 1659 buf = new char[bufsize+1];
12517 1659 pfread(buf, bufsize, f);
12518 1659 buf[bufsize]=0;
12519
12520 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12521 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12522 // Ignore these. -DD
12523
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 1113 times.
1659 if (id < NUMSCRIPTGLOBAL)
12524 {
12525 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12526
1/2
✓ Branch 0 taken 1113 times.
✗ Branch 1 not taken.
1113 if(strcmp(buf,"~Continue") == 0)
12527 {
12528 globalmap[id].scriptname = "";
12529
12530 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12531 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12532 }
12533 else
12534 {
12535 1113 globalmap[id].scriptname = buf;
12536 }
12537 1113 }
12538
12539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1659 times.
1659 delete[] buf;
12540 1659 }
12541
12542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(s_version > 3)
12543 {
12544 word numitembindings;
12545 408 p_igetw(&numitembindings, f);
12546
12547
2/2
✓ Branch 0 taken 1385 times.
✓ Branch 1 taken 408 times.
1793 for(int32_t i=0; i<numitembindings; i++)
12548 {
12549 word id;
12550 1385 p_igetw(&id, f);
12551 1385 p_igetl(&bufsize, f);
12552
2/4
✓ Branch 0 taken 1385 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1385 times.
1385 if (bufsize < 0 || bufsize > 1024)
12553 return qe_invalid;
12554 1385 buf = new char[bufsize+1];
12555 1385 pfread(buf, bufsize, f);
12556 1385 buf[bufsize]=0;
12557
12558 //fix this too
12559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1385 times.
1385 if(id <NUMSCRIPTITEM-1)
12560 1385 itemmap[id].scriptname = buf;
12561
12562
1/2
✓ Branch 0 taken 1385 times.
✗ Branch 1 not taken.
1385 delete[] buf;
12563 1385 }
12564 408 }
12565 //(v9+)
12566
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 208 times.
408 if(s_version > 8)
12567 {
12568 //npc scripts
12569 word numnpcbindings;
12570 208 p_igetw(&numnpcbindings, f);
12571
12572
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 208 times.
400 for(int32_t i=0; i<numnpcbindings; i++)
12573 {
12574 word id;
12575 192 p_igetw(&id, f);
12576 192 p_igetl(&bufsize, f);
12577
2/4
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
✗ Branch 3 not taken.
192 if (bufsize < 0 || bufsize > 1024)
12578 return qe_invalid;
12579 192 buf = new char[bufsize+1];
12580 192 pfread(buf, bufsize, f);
12581 192 buf[bufsize]=0;
12582
12583 //fix this too
12584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(id <NUMSCRIPTGUYS-1)
12585 192 npcmap[id].scriptname = buf;
12586
12587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 delete[] buf;
12588 192 }
12589 //lweapon
12590 word numlwpnbindings;
12591 208 p_igetw(&numlwpnbindings, f);
12592
12593
2/2
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 208 times.
635 for(int32_t i=0; i<numlwpnbindings; i++)
12594 {
12595 word id;
12596 427 p_igetw(&id, f);
12597 427 p_igetl(&bufsize, f);
12598
2/4
✓ Branch 0 taken 427 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 427 times.
427 if (bufsize < 0 || bufsize > 1024)
12599 return qe_invalid;
12600 427 buf = new char[bufsize+1];
12601 427 pfread(buf, bufsize, f);
12602 427 buf[bufsize]=0;
12603
12604 //fix this too
12605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 427 times.
427 if(id <NUMSCRIPTWEAPONS-1)
12606 427 lwpnmap[id].scriptname = buf;
12607
12608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 427 times.
427 delete[] buf;
12609 427 }
12610 //eweapon
12611 word numewpnbindings;
12612 208 p_igetw(&numewpnbindings, f);
12613
12614
2/2
✓ Branch 0 taken 437 times.
✓ Branch 1 taken 208 times.
645 for(int32_t i=0; i<numewpnbindings; i++)
12615 {
12616 word id;
12617 437 p_igetw(&id, f);
12618 437 p_igetl(&bufsize, f);
12619
2/4
✓ Branch 0 taken 437 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 437 times.
✗ Branch 3 not taken.
437 if (bufsize < 0 || bufsize > 1024)
12620 return qe_invalid;
12621 437 buf = new char[bufsize+1];
12622 437 pfread(buf, bufsize, f);
12623 437 buf[bufsize]=0;
12624
12625 //fix this too
12626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 437 times.
437 if(id <NUMSCRIPTWEAPONS-1)
12627 437 ewpnmap[id].scriptname = buf;
12628
12629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 437 times.
437 delete[] buf;
12630 437 }
12631 //hero
12632 word numherobindings;
12633 208 p_igetw(&numherobindings, f);
12634
12635
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 208 times.
251 for(int32_t i=0; i<numherobindings; i++)
12636 {
12637 word id;
12638 43 p_igetw(&id, f);
12639 43 p_igetl(&bufsize, f);
12640
2/4
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 43 times.
43 if (bufsize < 0 || bufsize > 1024)
12641 return qe_invalid;
12642 43 buf = new char[bufsize+1];
12643 43 pfread(buf, bufsize, f);
12644 43 buf[bufsize]=0;
12645
12646 //fix this too
12647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(id <NUMSCRIPTHERO-1)
12648 43 playermap[id].scriptname = buf;
12649
12650
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
43 delete[] buf;
12651 43 }
12652 //dmaps
12653 word numdmapbindings;
12654 208 p_igetw(&numdmapbindings, f);
12655
12656
2/2
✓ Branch 0 taken 543 times.
✓ Branch 1 taken 208 times.
751 for(int32_t i=0; i<numdmapbindings; i++)
12657 {
12658 word id;
12659 543 p_igetw(&id, f);
12660 543 p_igetl(&bufsize, f);
12661
2/4
✓ Branch 0 taken 543 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 543 times.
543 if (bufsize < 0 || bufsize > 1024)
12662 return qe_invalid;
12663 543 buf = new char[bufsize+1];
12664 543 pfread(buf, bufsize, f);
12665 543 buf[bufsize]=0;
12666
12667 //fix this too
12668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 543 times.
543 if(id <NUMSCRIPTSDMAP-1)
12669 543 dmapmap[id].scriptname = buf;
12670
12671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 543 times.
543 delete[] buf;
12672 543 }
12673 //screen
12674 word numscreenbindings;
12675 208 p_igetw(&numscreenbindings, f);
12676
12677
2/2
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 208 times.
647 for(int32_t i=0; i<numscreenbindings; i++)
12678 {
12679 word id;
12680 439 p_igetw(&id, f);
12681 439 p_igetl(&bufsize, f);
12682
2/4
✓ Branch 0 taken 439 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 439 times.
✗ Branch 3 not taken.
439 if (bufsize < 0 || bufsize > 1024)
12683 return qe_invalid;
12684 439 buf = new char[bufsize+1];
12685 439 pfread(buf, bufsize, f);
12686 439 buf[bufsize]=0;
12687
12688 //fix this too
12689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 439 times.
439 if(id <NUMSCRIPTSDMAP-1)
12690 439 screenmap[id].scriptname = buf;
12691
12692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 439 times.
439 delete[] buf;
12693 439 }
12694 208 }
12695
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 208 times.
408 if(s_version > 11)
12696 {
12697 word numspritebindings;
12698 208 p_igetw(&numspritebindings, f);
12699
12700
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 208 times.
279 for(int32_t i=0; i<numspritebindings; i++)
12701 {
12702 word id;
12703 71 p_igetw(&id, f);
12704 71 p_igetl(&bufsize, f);
12705
2/4
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 71 times.
71 if (bufsize < 0 || bufsize > 1024)
12706 return qe_invalid;
12707 71 buf = new char[bufsize+1];
12708 71 pfread(buf, bufsize, f);
12709 71 buf[bufsize]=0;
12710
12711 //fix this too
12712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 if(id <NUMSCRIPTSDMAP-1)
12713 71 itemspritemap[id].scriptname = buf;
12714
12715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 delete[] buf;
12716 71 }
12717 208 }
12718
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 208 times.
408 if(s_version >= 15)
12719 {
12720 word numcombobindings;
12721 208 p_igetw(&numcombobindings, f);
12722
12723
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 208 times.
425 for(int32_t i=0; i<numcombobindings; i++)
12724 {
12725 word id;
12726 217 p_igetw(&id, f);
12727 217 p_igetl(&bufsize, f);
12728
2/4
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
217 if (bufsize < 0 || bufsize > 1024)
12729 return qe_invalid;
12730 217 buf = new char[bufsize+1];
12731 217 pfread(buf, bufsize, f);
12732 217 buf[bufsize]=0;
12733
12734 //fix this too
12735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 if(id <NUMSCRIPTSCOMBODATA-1)
12736 217 comboscriptmap[id].scriptname = buf;
12737
12738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 delete[] buf;
12739 217 }
12740 208 }
12741
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 208 times.
408 if(s_version > 19)
12742 {
12743 word numgenericbindings;
12744 208 p_igetw(&numgenericbindings, f);
12745
12746
2/2
✓ Branch 0 taken 2288 times.
✓ Branch 1 taken 208 times.
2496 for(int32_t i=0; i<numgenericbindings; i++)
12747 {
12748 word id;
12749 2288 p_igetw(&id, f);
12750 2288 p_igetl(&bufsize, f);
12751
2/4
✓ Branch 0 taken 2288 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2288 times.
✗ Branch 3 not taken.
2288 if (bufsize < 0 || bufsize > 1024)
12752 return qe_invalid;
12753 2288 buf = new char[bufsize+1];
12754 2288 pfread(buf, bufsize, f);
12755 2288 buf[bufsize]=0;
12756
12757 //fix this too
12758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2288 times.
2288 if(id <NUMSCRIPTSGENERIC-1)
12759 2288 genericmap[id].scriptname = buf;
12760
12761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2288 times.
2288 delete[] buf;
12762 2288 }
12763 208 }
12764
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 191 times.
408 if(s_version > 21)
12765 {
12766 word numsubscreenbindings;
12767 191 p_igetw(&numsubscreenbindings, f);
12768
12769
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 191 times.
209 for(int32_t i=0; i<numsubscreenbindings; i++)
12770 {
12771 word id;
12772 18 p_igetw(&id, f);
12773 18 p_igetl(&bufsize, f);
12774
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 if (bufsize < 0 || bufsize > 1024)
12775 return qe_invalid;
12776 18 buf = new char[bufsize+1];
12777 18 pfread(buf, bufsize, f);
12778 18 buf[bufsize]=0;
12779
12780 //fix this too
12781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(id <NUMSCRIPTSSUBSCREEN-1)
12782 18 subscreenmap[id].scriptname = buf;
12783
12784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 delete[] buf;
12785 18 }
12786 191 }
12787 408 }
12788
12789 // Set ZScriptVersion to the value encoded in the script's meta.ffscript_v.
12790 // This is only updated when the scripts have been recompiled.
12791 // They should all match each other.
12792 408 std::optional<word> zscript_version;
12793
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 208 times.
408 if (s_version >= 16)
12794 {
12795
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 9416 times.
9622 for (auto script : read_scripts)
12796 {
12797
2/2
✓ Branch 0 taken 9414 times.
✓ Branch 1 taken 2 times.
9416 if (script->meta.ffscript_v == 0)
12798 {
12799 // These scripts were saved in a version prior to this field being set.
12800 // See https://discord.com/channels/876899628556091432/1368485306394738718
12801 2 zscript_version = 16;
12802 2 break;
12803 }
12804
1/2
✓ Branch 0 taken 9414 times.
✗ Branch 1 not taken.
9414 if (script->meta.ffscript_v > s_version)
12805 break;
12806
12807
2/2
✓ Branch 0 taken 9226 times.
✓ Branch 1 taken 188 times.
9414 if (!zscript_version.has_value())
12808 {
12809 188 zscript_version = script->meta.ffscript_v;
12810 188 continue;
12811 }
12812
12813
1/2
✓ Branch 0 taken 9226 times.
✗ Branch 1 not taken.
9226 if (zscript_version.value() != script->meta.ffscript_v)
12814 {
12815 zscript_version.reset();
12816 break;
12817 }
12818 }
12819
12820
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 18 times.
208 if (!zscript_version.has_value())
12821 18 al_trace("WARNING: Setting zscript version to section version as fallback.\n");
12822 208 }
12823 408 setZScriptVersion(zscript_version.value_or(s_version));
12824 408 read_scripts.clear();
12825
12826 408 return 0;
12827 408 }
12828
12829 void(*reset_scripts_hook)();
12830
12831 490 void reset_scripts()
12832 {
12833 // We can't modify the script data while jit threads are possibly compiling them.
12834
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 479 times.
490 if (reset_scripts_hook)
12835 479 reset_scripts_hook();
12836
12837
2/2
✓ Branch 0 taken 250880 times.
✓ Branch 1 taken 490 times.
251370 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12838 {
12839
1/2
✓ Branch 0 taken 250880 times.
✗ Branch 1 not taken.
250880 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12840 else genericscripts[i] = new script_data({ScriptType::Generic, i});
12841 250880 }
12842
12843
2/2
✓ Branch 0 taken 250880 times.
✓ Branch 1 taken 490 times.
251370 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12844 {
12845
1/2
✓ Branch 0 taken 250880 times.
✗ Branch 1 not taken.
250880 if (ffscripts[i])
12846 250880 ffscripts[i]->disable();
12847 else
12848 ffscripts[i] = new script_data(ScriptType::FFC, i);
12849 250880 }
12850
12851
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 490 times.
125930 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12852 {
12853
1/2
✓ Branch 0 taken 125440 times.
✗ Branch 1 not taken.
125440 if (itemscripts[i])
12854 125440 itemscripts[i]->disable();
12855 else
12856 itemscripts[i] = new script_data(ScriptType::Item, i);
12857 125440 }
12858
12859
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 490 times.
125930 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12860 {
12861
1/2
✓ Branch 0 taken 125440 times.
✗ Branch 1 not taken.
125440 if (guyscripts[i])
12862 125440 guyscripts[i]->disable();
12863 else
12864 guyscripts[i] = new script_data(ScriptType::NPC, i);
12865 125440 }
12866
12867
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 490 times.
125930 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12868 {
12869
1/2
✓ Branch 0 taken 125440 times.
✗ Branch 1 not taken.
125440 if (screenscripts[i])
12870 125440 screenscripts[i]->disable();
12871 else
12872 screenscripts[i] = new script_data(ScriptType::Screen, i);
12873 125440 }
12874
12875
2/2
✓ Branch 0 taken 3920 times.
✓ Branch 1 taken 490 times.
4410 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12876 {
12877
1/2
✓ Branch 0 taken 3920 times.
✗ Branch 1 not taken.
3920 if (globalscripts[i])
12878 3920 globalscripts[i]->disable();
12879 else
12880 globalscripts[i] = new script_data(ScriptType::Global, i);
12881 3920 }
12882
12883
2/2
✓ Branch 0 taken 2450 times.
✓ Branch 1 taken 490 times.
2940 for(int32_t i=0; i<NUMSCRIPTHERO; i++)
12884 {
12885
1/2
✓ Branch 0 taken 2450 times.
✗ Branch 1 not taken.
2450 if (playerscripts[i])
12886 2450 playerscripts[i]->disable();
12887 else
12888 playerscripts[i] = new script_data(ScriptType::Hero, i);
12889 2450 }
12890
12891
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 490 times.
125930 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12892 {
12893
1/2
✓ Branch 0 taken 125440 times.
✗ Branch 1 not taken.
125440 if (lwpnscripts[i])
12894 125440 lwpnscripts[i]->disable();
12895 else
12896 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
12897 125440 }
12898
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 490 times.
125930 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12899 {
12900
1/2
✓ Branch 0 taken 125440 times.
✗ Branch 1 not taken.
125440 if (ewpnscripts[i])
12901 125440 ewpnscripts[i]->disable();
12902 else
12903 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
12904 125440 }
12905
12906
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 490 times.
125930 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12907 {
12908
1/2
✓ Branch 0 taken 125440 times.
✗ Branch 1 not taken.
125440 if (dmapscripts[i])
12909 125440 dmapscripts[i]->disable();
12910 else
12911 dmapscripts[i] = new script_data(ScriptType::DMap, i);
12912 125440 }
12913
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 490 times.
125930 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12914 {
12915
1/2
✓ Branch 0 taken 125440 times.
✗ Branch 1 not taken.
125440 if (itemspritescripts[i])
12916 125440 itemspritescripts[i]->disable();
12917 else
12918 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
12919 125440 }
12920
2/2
✓ Branch 0 taken 250880 times.
✓ Branch 1 taken 490 times.
251370 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12921 {
12922
1/2
✓ Branch 0 taken 250880 times.
✗ Branch 1 not taken.
250880 if (comboscripts[i])
12923 250880 comboscripts[i]->disable();
12924 else
12925 comboscripts[i] = new script_data(ScriptType::Combo, i);
12926 250880 }
12927
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 125440 times.
125930 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
12928 {
12929
1/2
✓ Branch 0 taken 125440 times.
✗ Branch 1 not taken.
125440 if (subscreenscripts[i])
12930 125440 subscreenscripts[i]->disable();
12931 else
12932 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
12933 125440 }
12934 490 }
12935
12936 // 3.0+ calls this.
12937 142 int32_t read_quest_zasm(PACKFILE *f, word s_version)
12938 {
12939 int32_t num_commands;
12940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if(!p_igetl(&num_commands,f))
12941 return qe_invalid;
12942 #ifdef ZC_FUZZ
12943 const int32_t command_limit = 300000;
12944 #else
12945 142 const int32_t command_limit = 25000000;
12946 #endif
12947
2/4
✓ Branch 0 taken 142 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 142 times.
142 if (num_commands < 0 || num_commands > command_limit)
12948 return qe_invalid;
12949
12950 142 std::vector<ffscript> zasm;
12951
1/2
✓ Branch 0 taken 142 times.
✗ Branch 1 not taken.
142 zasm.reserve(num_commands);
12952
2/2
✓ Branch 0 taken 4384024 times.
✓ Branch 1 taken 142 times.
4384166 for(int32_t j=0; j<num_commands; j++)
12953 {
12954
1/2
✓ Branch 0 taken 4384024 times.
✗ Branch 1 not taken.
4384024 ffscript temp_script;
12955
2/4
✓ Branch 0 taken 4384024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4384024 times.
✗ Branch 3 not taken.
4384024 if(!p_igetw(&(temp_script.command),f))
12956 return qe_invalid;
12957
12958
2/4
✓ Branch 0 taken 4384024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4384024 times.
✗ Branch 3 not taken.
4384024 if(!p_igetl(&(temp_script.arg1),f))
12959 return qe_invalid;
12960
12961
2/4
✓ Branch 0 taken 4384024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4384024 times.
✗ Branch 3 not taken.
4384024 if(!p_igetl(&(temp_script.arg2),f))
12962 return qe_invalid;
12963
12964
2/4
✓ Branch 0 taken 4384024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4384024 times.
✗ Branch 3 not taken.
4384024 if(!p_igetl(&(temp_script.arg3),f))
12965 return qe_invalid;
12966
12967 4384024 uint32_t sz = 0;
12968
2/4
✓ Branch 0 taken 4384024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4384024 times.
✗ Branch 3 not taken.
4384024 if(!p_igetl(&sz,f))
12969 return qe_invalid;
12970
2/2
✓ Branch 0 taken 42551 times.
✓ Branch 1 taken 4341473 times.
4384024 if(sz) //string found
12971 {
12972
1/2
✓ Branch 0 taken 42551 times.
✗ Branch 1 not taken.
42551 temp_script.strptr = new std::string();
12973 char dummy;
12974
2/2
✓ Branch 0 taken 784841 times.
✓ Branch 1 taken 42551 times.
827392 for(size_t q = 0; q < sz; ++q)
12975 {
12976
2/4
✓ Branch 0 taken 784841 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 784841 times.
✗ Branch 3 not taken.
784841 if(!p_getc(&dummy,f))
12977 return qe_invalid;
12978
1/2
✓ Branch 0 taken 784841 times.
✗ Branch 1 not taken.
784841 temp_script.strptr->push_back(dummy);
12979 784841 }
12980 42551 }
12981
2/4
✓ Branch 0 taken 4384024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4384024 times.
✗ Branch 3 not taken.
4384024 if(!p_igetl(&sz,f))
12982 return qe_invalid;
12983
2/2
✓ Branch 0 taken 7457 times.
✓ Branch 1 taken 4376567 times.
4384024 if(sz) //vector found
12984 {
12985
1/2
✓ Branch 0 taken 7457 times.
✗ Branch 1 not taken.
7457 temp_script.vecptr = new std::vector<int32_t>();
12986 int32_t dummy;
12987
2/2
✓ Branch 0 taken 26289 times.
✓ Branch 1 taken 7457 times.
33746 for(size_t q = 0; q < sz; ++q)
12988 {
12989
2/4
✓ Branch 0 taken 26289 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26289 times.
✗ Branch 3 not taken.
26289 if(!p_igetl(&dummy,f))
12990 return qe_invalid;
12991
1/2
✓ Branch 0 taken 26289 times.
✗ Branch 1 not taken.
26289 temp_script.vecptr->push_back(dummy);
12992 26289 }
12993 7457 }
12994
1/2
✓ Branch 0 taken 4384024 times.
✗ Branch 1 not taken.
4384024 zasm.emplace_back(std::move(temp_script));
12995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4384024 times.
4384024 }
12996
12997
1/2
✓ Branch 0 taken 142 times.
✗ Branch 1 not taken.
142 assert(zasm_scripts.empty());
12998 142 zasm_script_id id = zasm_scripts.size();
12999
2/4
✓ Branch 0 taken 142 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 142 times.
142 zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, "@single", std::move(zasm)));
13000
13001 142 return 0;
13002 142 }
13003
13004 1105672 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, script_data *script, word zmeta_version)
13005 {
13006 ASSERT(script);
13007
2/2
✓ Branch 0 taken 558546 times.
✓ Branch 1 taken 547126 times.
1105672 if(s_version < 27)
13008 558546 return read_old_ffscript(f, script_index, s_version, script, zmeta_version);
13009
13010 char exists;
13011
1/2
✓ Branch 0 taken 547126 times.
✗ Branch 1 not taken.
547126 if (!p_getc(&exists, f))
13012 return qe_invalid;
13013
2/2
✓ Branch 0 taken 6372 times.
✓ Branch 1 taken 540754 times.
547126 if (!exists)
13014 {
13015 540754 script->disable();
13016 540754 return 0;
13017 }
13018
13019 //Read meta
13020 {
13021 6372 zasm_meta temp_meta;
13022
13023
2/4
✓ Branch 0 taken 6372 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6372 times.
✗ Branch 3 not taken.
6372 if(!p_igetw(&(temp_meta.zasm_v),f))
13024 return qe_invalid;
13025
2/4
✓ Branch 0 taken 6372 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6372 times.
✗ Branch 3 not taken.
6372 if(!p_igetw(&(temp_meta.meta_v),f))
13026 return qe_invalid;
13027
2/4
✓ Branch 0 taken 6372 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6372 times.
✗ Branch 3 not taken.
6372 if(!p_igetw(&(temp_meta.ffscript_v),f))
13028 return qe_invalid;
13029
2/4
✓ Branch 0 taken 6372 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6372 times.
✗ Branch 3 not taken.
6372 if(!p_getc(&(temp_meta.script_type),f))
13030 return qe_invalid;
13031
13032
2/2
✓ Branch 0 taken 50976 times.
✓ Branch 1 taken 6372 times.
57348 for(int32_t q = 0; q < 8; ++q)
13033 {
13034
2/4
✓ Branch 0 taken 50976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50976 times.
✗ Branch 3 not taken.
50976 if(!p_getcstr(&temp_meta.run_idens[q],f))
13035 return qe_invalid;
13036 50976 }
13037
13038
2/2
✓ Branch 0 taken 6372 times.
✓ Branch 1 taken 50976 times.
57348 for(int32_t q = 0; q < 8; ++q)
13039
2/4
✓ Branch 0 taken 50976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50976 times.
✗ Branch 3 not taken.
50976 if(!p_getc(&(temp_meta.run_types[q]),f))
13040 return qe_invalid;
13041
13042
2/4
✓ Branch 0 taken 6372 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6372 times.
✗ Branch 3 not taken.
6372 if(!p_getc(&(temp_meta.flags),f))
13043 return qe_invalid;
13044
13045
2/4
✓ Branch 0 taken 6372 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6372 times.
✗ Branch 3 not taken.
6372 if(!p_igetw(&(temp_meta.compiler_v1),f))
13046 return qe_invalid;
13047
2/4
✓ Branch 0 taken 6372 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6372 times.
✗ Branch 3 not taken.
6372 if(!p_igetw(&(temp_meta.compiler_v2),f))
13048 return qe_invalid;
13049
2/4
✓ Branch 0 taken 6372 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6372 times.
✗ Branch 3 not taken.
6372 if(!p_igetw(&(temp_meta.compiler_v3),f))
13050 return qe_invalid;
13051
2/4
✓ Branch 0 taken 6372 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6372 times.
✗ Branch 3 not taken.
6372 if(!p_igetw(&(temp_meta.compiler_v4),f))
13052 return qe_invalid;
13053
13054
2/4
✓ Branch 0 taken 6372 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6372 times.
✗ Branch 3 not taken.
6372 if(!p_getcstr(&temp_meta.script_name,f))
13055 return qe_invalid;
13056
2/4
✓ Branch 0 taken 6372 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6372 times.
✗ Branch 3 not taken.
6372 if(!p_getcstr(&temp_meta.author,f))
13057 return qe_invalid;
13058 6372 auto num_meta_attrib = 10;
13059
2/2
✓ Branch 0 taken 63720 times.
✓ Branch 1 taken 6372 times.
70092 for(auto q = 0; q < num_meta_attrib; ++q)
13060 {
13061
2/4
✓ Branch 0 taken 63720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63720 times.
✗ Branch 3 not taken.
63720 if(!p_getcstr(&temp_meta.attributes[q],f))
13062 return qe_invalid;
13063
2/4
✓ Branch 0 taken 63720 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63720 times.
✗ Branch 3 not taken.
63720 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13064 return qe_invalid;
13065 63720 }
13066
2/2
✓ Branch 0 taken 50976 times.
✓ Branch 1 taken 6372 times.
57348 for(auto q = 0; q < 8; ++q)
13067 {
13068
2/4
✓ Branch 0 taken 50976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50976 times.
✗ Branch 3 not taken.
50976 if(!p_getcstr(&temp_meta.attribytes[q],f))
13069 return qe_invalid;
13070
2/4
✓ Branch 0 taken 50976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50976 times.
✗ Branch 3 not taken.
50976 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
13071 return qe_invalid;
13072 50976 }
13073
2/2
✓ Branch 0 taken 50976 times.
✓ Branch 1 taken 6372 times.
57348 for(auto q = 0; q < 8; ++q)
13074 {
13075
2/4
✓ Branch 0 taken 50976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50976 times.
✗ Branch 3 not taken.
50976 if(!p_getcstr(&temp_meta.attrishorts[q],f))
13076 return qe_invalid;
13077
2/4
✓ Branch 0 taken 50976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50976 times.
✗ Branch 3 not taken.
50976 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
13078 return qe_invalid;
13079 50976 }
13080
2/2
✓ Branch 0 taken 101952 times.
✓ Branch 1 taken 6372 times.
108324 for(auto q = 0; q < 16; ++q)
13081 {
13082
2/4
✓ Branch 0 taken 101952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101952 times.
✗ Branch 3 not taken.
101952 if(!p_getcstr(&temp_meta.usrflags[q],f))
13083 return qe_invalid;
13084
2/4
✓ Branch 0 taken 101952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101952 times.
✗ Branch 3 not taken.
101952 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13085 return qe_invalid;
13086 101952 }
13087
2/2
✓ Branch 0 taken 50976 times.
✓ Branch 1 taken 6372 times.
57348 for(auto q = 0; q < 8; ++q)
13088 {
13089
2/4
✓ Branch 0 taken 50976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50976 times.
✗ Branch 3 not taken.
50976 if(!p_getcstr(&temp_meta.initd[q],f))
13090 return qe_invalid;
13091
2/4
✓ Branch 0 taken 50976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50976 times.
✗ Branch 3 not taken.
50976 if(!p_getwstr(&temp_meta.initd_help[q],f))
13092 return qe_invalid;
13093 50976 }
13094
2/2
✓ Branch 0 taken 6372 times.
✓ Branch 1 taken 50976 times.
57348 for(auto q = 0; q < 8; ++q)
13095 {
13096
2/4
✓ Branch 0 taken 50976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50976 times.
✗ Branch 3 not taken.
50976 if(!p_getc(&temp_meta.initd_type[q],f))
13097 return qe_invalid;
13098 50976 }
13099
13100
1/2
✓ Branch 0 taken 6372 times.
✗ Branch 1 not taken.
6372 script->meta = temp_meta;
13101
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6372 times.
6372 }
13102
1/2
✓ Branch 0 taken 6372 times.
✗ Branch 1 not taken.
6372 if(!p_igetl(&script->pc, f))
13103 return qe_invalid;
13104
1/2
✓ Branch 0 taken 6372 times.
✗ Branch 1 not taken.
6372 if(!p_igetl(&script->end_pc, f))
13105 return qe_invalid;
13106
13107
1/2
✓ Branch 0 taken 6372 times.
✗ Branch 1 not taken.
6372 if (script == &fake_script_data)
13108 return 0;
13109
13110
1/2
✓ Branch 0 taken 6372 times.
✗ Branch 1 not taken.
6372 assert(zasm_scripts.size() == 1);
13111 6372 auto& zs = zasm_scripts[0];
13112 6372 script->zasm_script = zs;
13113
13114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6372 times.
6372 if (script->valid())
13115 {
13116 6372 zs->script_datas.push_back(script);
13117 6372 read_scripts.push_back(script);
13118 6372 }
13119
13120 6372 return 0;
13121 1105672 }
13122
13123 558546 int32_t read_old_ffscript(PACKFILE *f, int32_t script_index, word s_version, script_data *script, word zmeta_version)
13124 {
13125 558546 char b33[34] = {0};
13126 558546 b33[33] = 0;
13127 558546 int32_t num_commands=1000;
13128
13129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 558546 times.
558546 if(s_version>=2)
13130 {
13131
1/2
✓ Branch 0 taken 558546 times.
✗ Branch 1 not taken.
558546 if(!p_igetl(&num_commands,f))
13132 {
13133 return qe_invalid;
13134 }
13135 558546 }
13136
13137 #ifdef ZC_FUZZ
13138 const int32_t command_limit = 300000;
13139 #else
13140 558546 const int32_t command_limit = 10000000;
13141 #endif
13142
2/4
✓ Branch 0 taken 558546 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 558546 times.
558546 if (num_commands < 0 || num_commands > command_limit)
13143 {
13144 return qe_invalid;
13145 }
13146
13147 558546 std::vector<ffscript> zasm;
13148
1/2
✓ Branch 0 taken 558546 times.
✗ Branch 1 not taken.
558546 zasm.reserve(num_commands);
13149
13150
2/2
✓ Branch 0 taken 249946 times.
✓ Branch 1 taken 308600 times.
558546 if(s_version >= 16)
13151 {
13152
1/2
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
249946 zasm_meta temp_meta;
13153
13154
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.zasm_v),f))
13155 {
13156 return qe_invalid;
13157 }
13158
13159
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.meta_v),f))
13160 {
13161 return qe_invalid;
13162 }
13163
13164
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.ffscript_v),f))
13165 {
13166 return qe_invalid;
13167 }
13168
13169
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_getc(&(temp_meta.script_type),f))
13170 {
13171 return qe_invalid;
13172 }
13173
13174
2/2
✓ Branch 0 taken 1999568 times.
✓ Branch 1 taken 249946 times.
2249514 for(int32_t q = 0; q < 8; ++q)
13175 {
13176
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 1855688 times.
1999568 if(zmeta_version < 3)
13177 {
13178
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 4748040 times.
4891920 for(int32_t c = 0; c < 33; ++c)
13179 {
13180
2/4
✓ Branch 0 taken 4748040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4748040 times.
✗ Branch 3 not taken.
4748040 if(!p_getc(&(b33[c]),f))
13181 {
13182 return qe_invalid;
13183 }
13184 4748040 }
13185
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.run_idens[q].assign(b33);
13186 143880 }
13187 else
13188 {
13189
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.run_idens[q],f))
13190 {
13191 return qe_invalid;
13192 }
13193 }
13194 1999568 }
13195
13196
2/2
✓ Branch 0 taken 249946 times.
✓ Branch 1 taken 1999568 times.
2249514 for(int32_t q = 0; q < 8; ++q)
13197 {
13198
2/4
✓ Branch 0 taken 1999568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1999568 times.
✗ Branch 3 not taken.
1999568 if(!p_getc(&(temp_meta.run_types[q]),f))
13199 {
13200 return qe_invalid;
13201 }
13202 1999568 }
13203
13204
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_getc(&(temp_meta.flags),f))
13205 {
13206 return qe_invalid;
13207 }
13208
13209
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v1),f))
13210 {
13211 return qe_invalid;
13212 }
13213
13214
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v2),f))
13215 {
13216 return qe_invalid;
13217 }
13218
13219
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v3),f))
13220 {
13221 return qe_invalid;
13222 }
13223
13224
2/4
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249946 times.
✗ Branch 3 not taken.
249946 if(!p_igetw(&(temp_meta.compiler_v4),f))
13225 {
13226 return qe_invalid;
13227 }
13228
13229
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 231961 times.
249946 if(zmeta_version == 2)
13230 {
13231
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13232 {
13233
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13234 {
13235 return qe_invalid;
13236 }
13237 593505 }
13238
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.script_name.assign(b33);
13239
13240
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
13241 {
13242
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
13243 {
13244 return qe_invalid;
13245 }
13246 593505 }
13247
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.author.assign(b33);
13248 17985 }
13249
1/2
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
231961 else if(zmeta_version > 2)
13250 {
13251
2/4
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231961 times.
✗ Branch 3 not taken.
231961 if(!p_getcstr(&temp_meta.script_name,f))
13252 return qe_invalid;
13253
2/4
✓ Branch 0 taken 231961 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231961 times.
✗ Branch 3 not taken.
231961 if(!p_getcstr(&temp_meta.author,f))
13254 return qe_invalid;
13255 231961 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13256
2/2
✓ Branch 0 taken 2319610 times.
✓ Branch 1 taken 231961 times.
2551571 for(auto q = 0; q < num_meta_attrib; ++q)
13257 {
13258
2/4
✓ Branch 0 taken 2319610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319610 times.
✗ Branch 3 not taken.
2319610 if(!p_getcstr(&temp_meta.attributes[q],f))
13259 return qe_invalid;
13260
2/4
✓ Branch 0 taken 2319610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2319610 times.
✗ Branch 3 not taken.
2319610 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13261 return qe_invalid;
13262 2319610 }
13263
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13264 {
13265
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.attribytes[q],f))
13266 return qe_invalid;
13267
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
13268 return qe_invalid;
13269 1855688 }
13270
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13271 {
13272
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.attrishorts[q],f))
13273 return qe_invalid;
13274
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
13275 return qe_invalid;
13276 1855688 }
13277
2/2
✓ Branch 0 taken 3711376 times.
✓ Branch 1 taken 231961 times.
3943337 for(auto q = 0; q < 16; ++q)
13278 {
13279
2/4
✓ Branch 0 taken 3711376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3711376 times.
✗ Branch 3 not taken.
3711376 if(!p_getcstr(&temp_meta.usrflags[q],f))
13280 return qe_invalid;
13281
2/4
✓ Branch 0 taken 3711376 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3711376 times.
✗ Branch 3 not taken.
3711376 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13282 return qe_invalid;
13283 3711376 }
13284 231961 }
13285
2/2
✓ Branch 0 taken 231961 times.
✓ Branch 1 taken 17985 times.
249946 if(zmeta_version > 3)
13286 {
13287
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13288 {
13289
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getcstr(&temp_meta.initd[q],f))
13290 return qe_invalid;
13291
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getwstr(&temp_meta.initd_help[q],f))
13292 return qe_invalid;
13293 1855688 }
13294
2/2
✓ Branch 0 taken 1855688 times.
✓ Branch 1 taken 231961 times.
2087649 for(auto q = 0; q < 8; ++q)
13295 {
13296
2/4
✓ Branch 0 taken 1855688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1855688 times.
✗ Branch 3 not taken.
1855688 if(!p_getc(&temp_meta.initd_type[q],f))
13297 return qe_invalid;
13298 1855688 }
13299 231961 }
13300 else
13301 {
13302
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 17985 times.
161865 for(auto q = 0; q < 8; ++q)
13303 {
13304
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.initd[q] = temp_meta.run_idens[q];
13305 143880 }
13306 }
13307
13308
1/2
✓ Branch 0 taken 249946 times.
✗ Branch 1 not taken.
249946 script->meta = temp_meta;
13309
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 249946 times.
✓ Branch 2 taken 308600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 308600 times.
✗ Branch 5 not taken.
558546 } else script->meta = {};
13310
13311
2/2
✓ Branch 0 taken 74674 times.
✓ Branch 1 taken 106040107 times.
106114781 for(int32_t j=0; j<num_commands; j++)
13312 {
13313
1/2
✓ Branch 0 taken 106040107 times.
✗ Branch 1 not taken.
106040107 auto& sc = zasm.emplace_back();
13314
2/4
✓ Branch 0 taken 106040107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106040107 times.
✗ Branch 3 not taken.
106040107 if(!p_igetw(&sc.command,f))
13315 {
13316 return qe_invalid;
13317 }
13318
13319
2/2
✓ Branch 0 taken 105556235 times.
✓ Branch 1 taken 483872 times.
106040107 if(sc.command == 0xFFFF)
13320 483872 break;
13321 else
13322 {
13323
2/4
✓ Branch 0 taken 105556235 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105556235 times.
✗ Branch 3 not taken.
105556235 if(!p_igetl(&sc.arg1,f))
13324 {
13325 return qe_invalid;
13326 }
13327
13328
2/4
✓ Branch 0 taken 105556235 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105556235 times.
✗ Branch 3 not taken.
105556235 if(!p_igetl(&sc.arg2,f))
13329 {
13330 return qe_invalid;
13331 }
13332
13333
2/2
✓ Branch 0 taken 1047747 times.
✓ Branch 1 taken 104508488 times.
105556235 if(s_version >= 24)
13334
2/4
✓ Branch 0 taken 1047747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1047747 times.
✗ Branch 3 not taken.
1047747 if(!p_igetl(&sc.arg3,f))
13335 return qe_invalid;
13336
13337
2/2
✓ Branch 0 taken 8222037 times.
✓ Branch 1 taken 97334198 times.
105556235 if(s_version >= 21)
13338 {
13339 8222037 uint32_t sz = 0;
13340
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13341 {
13342 return qe_invalid;
13343 }
13344
2/2
✓ Branch 0 taken 19400 times.
✓ Branch 1 taken 8202637 times.
8222037 if(sz) //string found
13345 {
13346
1/2
✓ Branch 0 taken 19400 times.
✗ Branch 1 not taken.
19400 sc.strptr = new std::string();
13347 char dummy;
13348
2/2
✓ Branch 0 taken 1165008 times.
✓ Branch 1 taken 19400 times.
1184408 for(size_t q = 0; q < sz; ++q)
13349 {
13350
2/4
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1165008 times.
✗ Branch 3 not taken.
1165008 if(!p_getc(&dummy,f))
13351 {
13352 return qe_invalid;
13353 }
13354
1/2
✓ Branch 0 taken 1165008 times.
✗ Branch 1 not taken.
1165008 sc.strptr->push_back(dummy);
13355 1165008 }
13356 19400 }
13357
2/4
✓ Branch 0 taken 8222037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8222037 times.
✗ Branch 3 not taken.
8222037 if(!p_igetl(&sz,f))
13358 {
13359 return qe_invalid;
13360 }
13361
2/2
✓ Branch 0 taken 933 times.
✓ Branch 1 taken 8221104 times.
8222037 if(sz) //vector found
13362 {
13363
1/2
✓ Branch 0 taken 933 times.
✗ Branch 1 not taken.
933 sc.vecptr = new std::vector<int32_t>();
13364 int32_t dummy;
13365
2/2
✓ Branch 0 taken 11526 times.
✓ Branch 1 taken 933 times.
12459 for(size_t q = 0; q < sz; ++q)
13366 {
13367
2/4
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11526 times.
✗ Branch 3 not taken.
11526 if(!p_igetl(&dummy,f))
13368 {
13369 return qe_invalid;
13370 }
13371
1/2
✓ Branch 0 taken 11526 times.
✗ Branch 1 not taken.
11526 sc.vecptr->push_back(dummy);
13372 11526 }
13373 933 }
13374 8222037 }
13375 }
13376 105556235 }
13377
13378
2/2
✓ Branch 0 taken 490450 times.
✓ Branch 1 taken 68096 times.
558546 if (script == &fake_script_data)
13379 68096 return 0;
13380
13381 // If the first command is unknown, invalidate the whole thing.
13382 // Saw this for https://www.purezc.net/index.php?page=quests&id=411 hero script 0
13383
5/6
✓ Branch 0 taken 421152 times.
✓ Branch 1 taken 69298 times.
✓ Branch 2 taken 409175 times.
✓ Branch 3 taken 11977 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 409175 times.
490450 if (!zasm.empty() && zasm[0].command >= NUMCOMMANDS && zasm[0].command != 0xFFFF)
13384 {
13385 al_trace("Warning: found script with bad instruction, disabling script: %s %d\n", ScriptTypeToString(script->id.type), script->id.index);
13386 zasm.clear();
13387 }
13388
13389 490450 zasm_script_id id = zasm_scripts.size();
13390
3/6
✓ Branch 0 taken 490450 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 490450 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 490450 times.
✗ Branch 5 not taken.
490450 auto& zs = zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, script->name(), std::move(zasm)));
13391 490450 script->zasm_script = zs;
13392 490450 script->pc = 0;
13393 490450 script->end_pc = zs->size;
13394
3/4
✓ Branch 0 taken 490450 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11977 times.
✓ Branch 3 taken 478473 times.
490450 if (script->valid())
13395 {
13396
1/2
✓ Branch 0 taken 11977 times.
✗ Branch 1 not taken.
11977 zs->script_datas.push_back(script);
13397
1/2
✓ Branch 0 taken 11977 times.
✗ Branch 1 not taken.
11977 read_scripts.push_back(script);
13398 11977 }
13399
13400 490450 return 0;
13401 558546 }
13402
13403 extern SAMPLE customsfxdata[WAV_COUNT];
13404 extern uint8_t customsfxflag[WAV_COUNT>>3];
13405 extern int32_t sfxdat;
13406 extern DATAFILE *sfxdata;
13407 const char *old_sfx_string[Z35] =
13408 {
13409 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13410 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13411 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13412 "Hookshot", "Message", "Hero is hit", "Item fanfare", "Bomb placed", "Item pickup",
13413 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13414 "Secret chime", "Hero dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13415 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13416 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13417 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13418 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13419 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13420 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13421 };
13422 char *sfx_string[WAV_COUNT];
13423
13424 408 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13425 {
13426 //these are here to bypass compiler warnings about unused arguments
13427 408 Header=Header;
13428
13429 int32_t dummy;
13430 408 word s_version=0;
13431 //int32_t ret;
13432 408 SAMPLE temp_sample = {};
13433 408 temp_sample.loop_start=0;
13434 408 temp_sample.loop_end=0;
13435 408 temp_sample.param=0;
13436
13437 //section version info
13438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(!p_igetw(&s_version,f))
13439 {
13440 return qe_invalid;
13441 }
13442
13443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if (s_version > V_SFX)
13444 return qe_version;
13445
13446 408 FFCore.quest_format[vSFX] = s_version;
13447
13448
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!read_deprecated_section_cversion(f))
13449 {
13450 return qe_invalid;
13451 }
13452
13453 //section size
13454
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_igetl(&dummy,f))
13455 {
13456 return qe_invalid;
13457 }
13458
13459 /* HIGHLY UNORTHODOX UPDATING THING, by L
13460 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13461 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13462 * changing from 1 to 2.
13463 */
13464
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(s_version < 2)
13465 set_qr(qr_GOTOLESSNOTEQUAL,1);
13466
13467 /* End highly unorthodox updating thing */
13468
13469 408 int32_t wavcount = WAV_COUNT;
13470
13471
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(s_version < 6)
13472 wavcount = 128;
13473
13474 uint8_t tempflag[WAV_COUNT>>3];
13475
13476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(s_version < 4)
13477 {
13478 memset(tempflag, 0xFF, WAV_COUNT>>3);
13479 }
13480 else
13481 {
13482
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(s_version < 6)
13483 memset(tempflag, 0, WAV_COUNT>>3);
13484
13485
2/2
✓ Branch 0 taken 13056 times.
✓ Branch 1 taken 408 times.
13464 for(int32_t i=0; i<(wavcount>>3); i++)
13486 {
13487 13056 p_getc(&tempflag[i], f);
13488 13056 }
13489
13490 }
13491
13492
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(s_version>4)
13493 {
13494
2/2
✓ Branch 0 taken 104040 times.
✓ Branch 1 taken 408 times.
104448 for(int32_t i=1; i<WAV_COUNT; i++)
13495 {
13496 104040 sprintf(sfx_string[i],"s%03d",i);
13497
13498
2/2
✓ Branch 0 taken 79560 times.
✓ Branch 1 taken 24480 times.
104040 if((i<Z35))
13499 24480 strcpy(sfx_string[i], old_sfx_string[i-1]);
13500
13501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104040 times.
104040 if(i>=wavcount)
13502 continue;
13503
2/2
✓ Branch 0 taken 22630 times.
✓ Branch 1 taken 81410 times.
104040 if(get_bit(tempflag, i-1))
13504 {
13505 char tempname[36];
13506
13507
1/2
✓ Branch 0 taken 22630 times.
✗ Branch 1 not taken.
22630 if(!pfread(tempname, 36, f))
13508 {
13509 return qe_invalid;
13510 }
13511
13512 22630 sfx_string[i][0] = '\0';
13513 22630 strncat(sfx_string[i], tempname, 36 - 1);
13514 22630 }
13515 else
13516 {
13517 81410 sprintf(sfx_string[i],"s%03d",i);
13518
13519
2/2
✓ Branch 0 taken 71720 times.
✓ Branch 1 taken 9690 times.
81410 if(i<Z35)
13520 9690 strcpy(sfx_string[i], old_sfx_string[i-1]);
13521 81410 sfx_string[i][35] = 0; //Force NULL Termination
13522 }
13523 104040 }
13524 408 }
13525 else
13526 {
13527 for(int32_t i=1; i<WAV_COUNT; i++)
13528 {
13529 sprintf(sfx_string[i],"s%03d",i);
13530
13531 if(i<Z35)
13532 strcpy(sfx_string[i], old_sfx_string[i-1]);
13533 }
13534 }
13535
13536 //finally... section data
13537
2/2
✓ Branch 0 taken 104040 times.
✓ Branch 1 taken 408 times.
104448 for(int32_t i=1; i<wavcount; i++)
13538 {
13539
2/2
✓ Branch 0 taken 22630 times.
✓ Branch 1 taken 81410 times.
104040 if(get_bit(tempflag, i-1))
13540 {
13541
13542
1/2
✓ Branch 0 taken 22630 times.
✗ Branch 1 not taken.
22630 if(!p_igetl(&dummy,f))
13543 {
13544 return qe_invalid;
13545 }
13546
13547 22630 (temp_sample.bits) = dummy;
13548
13549
1/2
✓ Branch 0 taken 22630 times.
✗ Branch 1 not taken.
22630 if(!p_igetl(&dummy,f))
13550 {
13551 return qe_invalid;
13552 }
13553
13554 22630 (temp_sample.stereo) = dummy;
13555
13556
1/2
✓ Branch 0 taken 22630 times.
✗ Branch 1 not taken.
22630 if(!p_igetl(&dummy,f))
13557 {
13558 return qe_invalid;
13559 }
13560
13561 22630 (temp_sample.freq) = dummy;
13562
13563
1/2
✓ Branch 0 taken 22630 times.
✗ Branch 1 not taken.
22630 if(!p_igetl(&dummy,f))
13564 {
13565 return qe_invalid;
13566 }
13567
13568 22630 (temp_sample.priority) = dummy;
13569
13570
1/2
✓ Branch 0 taken 22630 times.
✗ Branch 1 not taken.
22630 if(!p_igetl(&(temp_sample.len),f))
13571 {
13572 return qe_invalid;
13573 }
13574
13575
1/2
✓ Branch 0 taken 22630 times.
✗ Branch 1 not taken.
22630 if(!p_igetl(&(temp_sample.loop_start),f))
13576 {
13577 return qe_invalid;
13578 }
13579
13580
1/2
✓ Branch 0 taken 22630 times.
✗ Branch 1 not taken.
22630 if(!p_igetl(&(temp_sample.loop_end),f))
13581 {
13582 return qe_invalid;
13583 }
13584
13585
1/2
✓ Branch 0 taken 22630 times.
✗ Branch 1 not taken.
22630 if(!p_igetl(&(temp_sample.param),f))
13586 {
13587 return qe_invalid;
13588 }
13589
13590 22630 auto len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13591 #ifdef ZC_FUZZ
13592 const int32_t sfx_limit = 100000;
13593 if (len < 0 || len > sfx_limit)
13594 {
13595 return qe_invalid;
13596 }
13597 #endif
13598 22630 temp_sample.data = calloc(len,1);
13599
13600
1/2
✓ Branch 0 taken 22630 times.
✗ Branch 1 not taken.
22630 if(s_version < 3)
13601 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13602
13603 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22630 times.
22630 if(s_version < 2)
13605 {
13606 if(!pfread(temp_sample.data, len,f))
13607 {
13608 return qe_invalid;
13609 }
13610 }
13611 else
13612 {
13613 //re-endianfy the data
13614 22630 int32_t wordstoread = len / sizeof(word);
13615
13616
2/2
✓ Branch 0 taken 655546238 times.
✓ Branch 1 taken 22630 times.
655568868 for(int32_t j=0; j<wordstoread; j++)
13617 {
13618 word temp;
13619
13620
1/2
✓ Branch 0 taken 655546238 times.
✗ Branch 1 not taken.
655546238 if(!p_igetw(&temp, f))
13621 {
13622 return qe_invalid;
13623 }
13624
13625 655546238 ((word *)temp_sample.data)[j] = temp;
13626 655546238 }
13627 }
13628 22630 }
13629
2/2
✓ Branch 0 taken 9690 times.
✓ Branch 1 taken 71720 times.
81410 else if(i < Z35)
13630 {
13631 9690 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13632 9690 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13633 9690 set_bit(tempflag, i-1, 1);
13634 9690 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13635 9690 temp_sample.data = calloc(len,1);
13636 9690 memcpy(temp_sample.data, datsamp->data, len);
13637 9690 }
13638 71720 else continue;
13639
13640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32320 times.
32320 if(customsfxdata[i].data!=NULL)
13641 {
13642 // delete [] customsfxdata[i].data;
13643 32320 free(customsfxdata[i].data);
13644 32320 }
13645
13646 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13647 32320 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13648 32320 customsfxdata[i].data = calloc(len2,1);
13649 32320 customsfxdata[i].bits = temp_sample.bits;
13650 32320 customsfxdata[i].stereo = temp_sample.stereo;
13651 32320 customsfxdata[i].freq = temp_sample.freq;
13652 32320 customsfxdata[i].priority = temp_sample.priority;
13653 32320 customsfxdata[i].len = temp_sample.len;
13654 32320 customsfxdata[i].loop_start = temp_sample.loop_start;
13655 32320 customsfxdata[i].loop_end = temp_sample.loop_end;
13656 32320 customsfxdata[i].param = temp_sample.param;
13657 32320 int32_t cpylen = len2;
13658
13659
1/2
✓ Branch 0 taken 32320 times.
✗ Branch 1 not taken.
32320 if(s_version<3)
13660 {
13661 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13662 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13663 }
13664
13665 32320 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13666
13667 32320 free(temp_sample.data);
13668 32320 }
13669
13670 408 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13671
13672 408 sfxdat=0;
13673 408 return 0;
13674 408 }
13675
13676 490 void setupsfx()
13677 {
13678
2/2
✓ Branch 0 taken 124950 times.
✓ Branch 1 taken 490 times.
125440 for(int32_t i=1; i<WAV_COUNT; i++)
13679 {
13680 124950 sprintf(sfx_string[i],"s%03d",i);
13681
13682
2/2
✓ Branch 0 taken 95550 times.
✓ Branch 1 taken 29400 times.
124950 if(i<Z35)
13683 {
13684 29400 strcpy(sfx_string[i], old_sfx_string[i-1]);
13685 29400 }
13686
13687 124950 memset(customsfxflag, 0, WAV_COUNT>>3);
13688
13689 124950 int32_t j=i;
13690
13691
2/2
✓ Branch 0 taken 29890 times.
✓ Branch 1 taken 95060 times.
124950 if(i>Z35)
13692 {
13693 95060 i=Z35;
13694 95060 }
13695
13696 124950 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13697
13698
2/2
✓ Branch 0 taken 96390 times.
✓ Branch 1 taken 28560 times.
124950 if(customsfxdata[j].data!=NULL)
13699 {
13700 // delete [] customsfxdata[j].data;
13701 28560 free(customsfxdata[j].data);
13702 28560 }
13703
13704 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13705 124950 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13706 124950 customsfxdata[j].bits = temp_sample->bits;
13707 124950 customsfxdata[j].stereo = temp_sample->stereo;
13708 124950 customsfxdata[j].freq = temp_sample->freq;
13709 124950 customsfxdata[j].priority = temp_sample->priority;
13710 124950 customsfxdata[j].len = temp_sample->len;
13711 124950 customsfxdata[j].loop_start = temp_sample->loop_start;
13712 124950 customsfxdata[j].loop_end = temp_sample->loop_end;
13713 124950 customsfxdata[j].param = temp_sample->param;
13714 124950 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13715 124950 i=j;
13716 124950 }
13717 490 }
13718
13719 extern char *guy_string[eMAXGUYS];
13720 extern const char *old_guy_string[OLDMAXGUYS];
13721
13722 490 int32_t readguys(PACKFILE *f, zquestheader *Header)
13723 {
13724
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 23 times.
490 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_guys);
13725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 490 times.
490 if (should_skip) return 0;
13726
13727 dword dummy;
13728 word guy_cversion;
13729 490 word guyversion=0;
13730
13731
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 467 times.
490 if(Header->zelda_version >= 0x193)
13732 {
13733 //section version info
13734
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if(!p_igetw(&guyversion,f))
13735 {
13736 return qe_invalid;
13737 }
13738
13739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if (guyversion > V_GUYS)
13740 return qe_version;
13741
13742 467 FFCore.quest_format[vGuys] = guyversion;
13743
13744 // Note: this is the only instance where "cversion" is ever used.
13745
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if(!p_igetw(&guy_cversion,f))
13746 {
13747 return qe_invalid;
13748 }
13749
13750 //section size
13751
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if(!p_igetl(&dummy,f))
13752 {
13753 return qe_invalid;
13754 }
13755 467 }
13756
13757
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 82 times.
490 if(guyversion > 3)
13758 {
13759
2/2
✓ Branch 0 taken 208896 times.
✓ Branch 1 taken 408 times.
209304 for(int32_t i=0; i<MAXGUYS; i++)
13760 {
13761 char tempname[64];
13762
13763 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13764 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13765
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 208896 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
208896 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13766 {
13767 memset(tempname, 0, sizeof(char)*64);
13768 sprintf(tempname, "e%03d", i);
13769 strcpy(guy_string[i], tempname);
13770
13771 continue;
13772 }
13773
13774
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!pfread(tempname, 64, f))
13775 {
13776 return qe_invalid;
13777 }
13778
13779 // Don't retain names of uneditable enemy entries!
13780 // for version upgrade to 2.5
13781
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 208896 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
208896 if(guyversion < 23 && i >= 177)
13782 {
13783 // some of the older builds have names such as 'zz123',
13784 // (this order gets messed up with some eXXX and some zzXXX)
13785 // so let's update to the newer naming convection. -Gleeok
13786 char tmpbuf[64];
13787 memset(tmpbuf, 0, sizeof(char)*64);
13788 sprintf(tmpbuf, "zz%03d", i);
13789
13790 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13791 {
13792 memset(tempname, 0, sizeof(char)*64);
13793 sprintf(tempname, "e%03d", i);
13794 }
13795 }
13796
13797
6/6
✓ Branch 0 taken 72216 times.
✓ Branch 1 taken 136680 times.
✓ Branch 2 taken 68544 times.
✓ Branch 3 taken 3672 times.
✓ Branch 4 taken 59904 times.
✓ Branch 5 taken 8640 times.
208896 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13798 {
13799 200256 guy_string[i][0] = '\0';
13800 200256 strncat(guy_string[i], tempname, 64 - 1);
13801 200256 }
13802 else
13803 {
13804 8640 strcpy(guy_string[i],old_guy_string[i]);
13805 }
13806 208896 }
13807 408 }
13808 else
13809 {
13810
2/2
✓ Branch 0 taken 41984 times.
✓ Branch 1 taken 82 times.
42066 for(int32_t i=0; i<eMAXGUYS; i++)
13811 {
13812 41984 sprintf(guy_string[i],"zz%03d",i);
13813 41984 }
13814
13815
2/2
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 82 times.
14596 for(int32_t i=0; i<OLDMAXGUYS; i++)
13816 {
13817 14514 strcpy(guy_string[i],old_guy_string[i]);
13818 14514 }
13819 }
13820
13821
13822 //finally... section data
13823 490 init_guys(guyversion); //using default data for now...
13824
13825 // Goriya guy fix
13826
3/6
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 408 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
490 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13827 {
13828
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 60 times.
82 if(get_qr(qr_NEWENEMYTILES))
13829 {
13830 60 guysbuf[gGORIYA].tile=130;
13831 60 guysbuf[gGORIYA].e_tile=130;
13832 60 }
13833 82 }
13834
13835
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 23 times.
490 if(Header->zelda_version < 0x193)
13836 {
13837
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 5 times.
23 if(get_bit(deprecated_rules,46))
13838 {
13839 5 guysbuf[eDODONGO].cset=14;
13840 5 guysbuf[eDODONGO].bosspal=spDIG;
13841 5 }
13842 23 }
13843 // Not sure when this first changed, but it's necessary for 2.10, at least
13844 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13845 //2.10 Fixes
13846
3/6
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 408 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
490 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13847 {
13848 82 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13849 82 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13850 82 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13851 82 guysbuf[eCENT1].attributes[2] = 1;
13852 82 guysbuf[eCENT2].attributes[2] = 1;
13853 82 }
13854
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 490 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
490 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13855 {
13856 490 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13857 490 }
13858
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 82 times.
490 if(Header->zelda_version <= 0x210)
13859 {
13860 82 guysbuf[eGLEEOK1F].attributes[5] = 16;
13861 82 guysbuf[eGLEEOK2F].attributes[5] = 16;
13862 82 guysbuf[eGLEEOK3F].attributes[5] = 16;
13863 82 guysbuf[eGLEEOK4F].attributes[5] = 16;
13864
13865 82 guysbuf[eWIZ1].attributes[3] = 1; //only set the enemy that needs backward compat, not all of them.
13866 82 guysbuf[eBATROBE].attributes[3] = 1;
13867 //guysbuf[eSUMMONER].misc4 = 1;
13868 82 guysbuf[eWWIZ].attributes[3] = 1;
13869 82 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13870 82 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13871 82 }
13872
2/2
✓ Branch 0 taken 478 times.
✓ Branch 1 taken 12 times.
490 if(Header->zelda_version == 0x190)
13873 {
13874 12 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13875 12 guysbuf[eKEESETRIB].attributes[2] = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13876 12 guysbuf[eGELTRIB].attributes[2] = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13877 12 }
13878
13879 // The versions here may not be correct
13880 // zelda_version>=0x211 handled at guyversion<24
13881
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 472 times.
490 if(Header->zelda_version <= 0x190)
13882 {
13883 18 guysbuf[eCENT1].attributes[2] = 0;
13884 18 guysbuf[eCENT2].attributes[2] = 0;
13885 18 guysbuf[eMOLDORM].attributes[1] = 0;
13886 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13887 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13888 18 }
13889
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 64 times.
472 else if(Header->zelda_version <= 0x210)
13890 {
13891 64 guysbuf[eCENT1].attributes[2] = 1;
13892 64 guysbuf[eCENT2].attributes[2] = 1;
13893 64 guysbuf[eMOLDORM].attributes[1] = 0;
13894 64 }
13895
13896
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 82 times.
490 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13897 {
13898 82 guysbuf[eKEESE1].attributes[15] = 120;
13899 82 guysbuf[eKEESE2].attributes[15] = 120;
13900 82 guysbuf[eKEESE3].attributes[15] = 120;
13901 82 guysbuf[eKEESETRIB].attributes[15] = 120;
13902 82 guysbuf[eKEESE1].attributes[16] = 16;
13903 82 guysbuf[eKEESE2].attributes[16] = 16;
13904 82 guysbuf[eKEESE3].attributes[16] = 16;
13905 82 guysbuf[eKEESETRIB].attributes[16] = 16;
13906
13907 82 guysbuf[ePEAHAT].attributes[15] = 80;
13908 82 guysbuf[ePEAHAT].attributes[16] = 16;
13909
13910 82 guysbuf[eGHINI2].attributes[15] = 120;
13911 82 guysbuf[eGHINI2].attributes[16] = 10;
13912
13913
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 66 times.
82 if (replay_version_check(20))
13914 {
13915 66 guysbuf[eGHINI2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13916 66 guysbuf[eMOLDORM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13917 66 guysbuf[eKEESETRIB].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13918 66 guysbuf[eKEESE3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13919 66 guysbuf[eKEESE2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13920 66 guysbuf[eKEESE1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13921 66 guysbuf[eTEK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13922 66 guysbuf[eTEK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13923 66 guysbuf[ePEAHAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13924 66 guysbuf[eROCK].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13925 66 guysbuf[eTRAP].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13926 66 guysbuf[eWALLM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13927 66 guysbuf[ePOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13928 66 guysbuf[eMANHAN].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13929 66 guysbuf[eGLEEOK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13930 66 guysbuf[eGLEEOK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13931 66 guysbuf[eGLEEOK3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13932 66 guysbuf[eGLEEOK4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13933 66 guysbuf[eDIG1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13934 66 guysbuf[eDIG3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13935 66 guysbuf[eDIGPUP1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13936 66 guysbuf[eDIGPUP2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13937 66 guysbuf[eDIGPUP3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13938 66 guysbuf[eDIGPUP4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13939 66 guysbuf[eRAQUAM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13940 66 guysbuf[eITEMFAIRY].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13941 66 guysbuf[eFIRE].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13942 66 guysbuf[eMANHAN2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13943 66 guysbuf[eTRAP_H].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13944 66 guysbuf[eTRAP_V].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13945 66 guysbuf[eTRAP_LR].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13946 66 guysbuf[eTRAP_UD].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13947 66 guysbuf[ePATRA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13948 66 guysbuf[ePATRA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13949 66 guysbuf[ePATRABS].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13950 66 guysbuf[eBAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13951 66 guysbuf[eGLEEOK1F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13952 66 guysbuf[eGLEEOK2F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13953 66 guysbuf[eGLEEOK3F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13954 66 guysbuf[eGLEEOK4F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13955 66 guysbuf[eTRIGGER].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13956 66 guysbuf[ePATRAL2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13957 66 guysbuf[ePATRAL3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13958 66 guysbuf[eGOHMA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13959 66 guysbuf[eGOHMA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13960 66 guysbuf[eGOHMA3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13961 66 guysbuf[eGOHMA4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13962 66 guysbuf[eMPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13963 66 guysbuf[eWPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13964 66 }
13965 82 }
13966
13967
13968
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 408 times.
490 if(guyversion<=2)
13969 {
13970 82 return readherosprites2(f, guyversion==2?0:-1);
13971 }
13972
13973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(guyversion > 3)
13974 {
13975 408 guydata tempguy;
13976
13977
2/2
✓ Branch 0 taken 208896 times.
✓ Branch 1 taken 408 times.
209304 for(int32_t i=0; i<MAXGUYS; i++)
13978 {
13979
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(guyversion < 23) // May 2012 : 512 max enemies
13980 {
13981 if(i >= OLDBETAMAXGUYS)
13982 {
13983 guysbuf[i].clear();
13984 continue;
13985 }
13986 }
13987
13988 208896 tempguy.clear();
13989
13990 uint32_t flags1;
13991 uint32_t flags2;
13992
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetl(&(flags1),f))
13993 {
13994 return qe_invalid;
13995 }
13996
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetl(&(flags2),f))
13997 {
13998 return qe_invalid;
13999 }
14000 208896 tempguy.flags = guy_flags(flags1) | guy_flags(uint64_t(flags2)<<32ULL);
14001
14002
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 102400 times.
208896 if ( guyversion >= 36 ) //expanded tiles
14003 {
14004
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.tile),f))
14005 {
14006 return qe_invalid;
14007 }
14008 106496 }
14009 else
14010 {
14011
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetw(&(tempguy.tile),f))
14012 {
14013 return qe_invalid;
14014 }
14015 }
14016
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_getc(&(tempguy.width),f))
14017 {
14018 return qe_invalid;
14019 }
14020
14021
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_getc(&(tempguy.height),f))
14022 {
14023 return qe_invalid;
14024 }
14025
14026
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 102400 times.
208896 if ( guyversion >= 36 ) //expanded tiles
14027 {
14028
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.s_tile),f))
14029 {
14030 return qe_invalid;
14031 }
14032 106496 }
14033 else
14034 {
14035
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetw(&(tempguy.s_tile),f))
14036 {
14037 return qe_invalid;
14038 }
14039 }
14040
14041
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_getc(&(tempguy.s_width),f))
14042 {
14043 return qe_invalid;
14044 }
14045
14046
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_getc(&(tempguy.s_height),f))
14047 {
14048 return qe_invalid;
14049 }
14050
14051
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 102400 times.
208896 if ( guyversion >= 36 ) //expanded tiles
14052 {
14053
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.e_tile),f))
14054 {
14055 return qe_invalid;
14056 }
14057 106496 }
14058 else
14059 {
14060
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetw(&(tempguy.e_tile),f))
14061 {
14062 return qe_invalid;
14063 }
14064 }
14065
14066
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_getc(&(tempguy.e_width),f))
14067 {
14068 return qe_invalid;
14069 }
14070
14071
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_getc(&(tempguy.e_height),f))
14072 {
14073 return qe_invalid;
14074 }
14075
14076
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetw(&(tempguy.hp),f))
14077 {
14078 return qe_invalid;
14079 }
14080
14081
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetw(&(tempguy.type),f))
14082 {
14083 return qe_invalid;
14084 }
14085
14086
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 208896 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
208896 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
14087 {
14088 if(get_qr(qr_NEWENEMYTILES))
14089 {
14090 tempguy.s_tile=tempguy.e_tile+120;
14091 tempguy.s_width=tempguy.e_width;
14092 tempguy.s_height=tempguy.e_height;
14093 }
14094 else tempguy.s_tile=860;
14095 }
14096
14097
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetw(&(tempguy.cset),f))
14098 {
14099 return qe_invalid;
14100 }
14101
14102
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetw(&(tempguy.anim),f))
14103 {
14104 return qe_invalid;
14105 }
14106
14107
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetw(&(tempguy.e_anim),f))
14108 {
14109 return qe_invalid;
14110 }
14111
14112
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetw(&(tempguy.frate),f))
14113 {
14114 return qe_invalid;
14115 }
14116
14117
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetw(&(tempguy.e_frate),f))
14118 {
14119 return qe_invalid;
14120 }
14121
14122
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(guyversion < 13) // April 2009
14123 {
14124 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
14125 {
14126 tempguy.frate *= 2;
14127 tempguy.e_frate *= 2;
14128 }
14129 }
14130
14131
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(guyversion < 14) // May 1 2009
14132 {
14133 if(tempguy.anim==a2FRMSLOW)
14134 {
14135 tempguy.anim=a2FRM;
14136 tempguy.frate *= 2;
14137 }
14138
14139 if(tempguy.e_anim==a2FRMSLOW)
14140 {
14141 tempguy.e_anim=a2FRM;
14142 tempguy.e_frate *= 2;
14143 }
14144
14145 if(tempguy.anim==aFLIPSLOW)
14146 {
14147 tempguy.anim=aFLIP;
14148 tempguy.frate *= 2;
14149 }
14150
14151 if(tempguy.e_anim==aFLIPSLOW)
14152 {
14153 tempguy.e_anim=aFLIP;
14154 tempguy.e_frate *= 2;
14155 }
14156
14157 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14158
14159 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14160
14161 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14162 {
14163 tempguy.anim=a4FRM4DIR;
14164 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14165 }
14166
14167 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14168 {
14169 tempguy.e_anim=a4FRM4DIR;
14170 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14171 }
14172 }
14173
14174
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetw(&(tempguy.dp),f))
14175 {
14176 return qe_invalid;
14177 }
14178
14179 //correction for guy fire
14180
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(guyversion < 6)
14181 {
14182 if(i == gFIRE)
14183 tempguy.dp = 2;
14184 }
14185
14186
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetw(&(tempguy.wdp),f))
14187 {
14188 return qe_invalid;
14189 }
14190
14191
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetw(&(tempguy.weapon),f))
14192 {
14193 return qe_invalid;
14194 }
14195
14196 //correction for bosses using triple, "rising" fireballs
14197
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(guyversion < 5)
14198 {
14199 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14200 i == eGOHMA3 || i == eGOHMA4)
14201 {
14202 if(tempguy.weapon == ewFireball)
14203 tempguy.weapon = ewFireball2;
14204 }
14205 }
14206
14207
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetw(&(tempguy.rate),f))
14208 {
14209 return qe_invalid;
14210 }
14211
14212
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetw(&(tempguy.hrate),f))
14213 {
14214 return qe_invalid;
14215 }
14216
14217
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetw(&(tempguy.step),f))
14218 {
14219 return qe_invalid;
14220 }
14221
14222 // HIGHLY UNORTHODOX UPDATING THING, part 2
14223
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 208896 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
208896 if(fixpolsvoice && tempguy.type==eePOLSV)
14224 {
14225 tempguy.step /= 2;
14226 }
14227
14228
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetw(&(tempguy.homing),f))
14229 {
14230 return qe_invalid;
14231 }
14232
14233
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetw(&(tempguy.grumble),f))
14234 {
14235 return qe_invalid;
14236 }
14237
14238
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetw(&(tempguy.item_set),f))
14239 {
14240 return qe_invalid;
14241 }
14242
14243
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14244 {
14245
2/2
✓ Branch 0 taken 2088960 times.
✓ Branch 1 taken 208896 times.
2297856 for (int q = 0; q < 10; ++q)
14246 {
14247
1/2
✓ Branch 0 taken 2088960 times.
✗ Branch 1 not taken.
2088960 if (!p_igetl(&(tempguy.attributes[q]), f))
14248 {
14249 return qe_invalid;
14250 }
14251 2088960 }
14252 208896 }
14253 else
14254 {
14255 int16_t tempMisc;
14256
14257 for(int q=0;q<10;q++)
14258 {
14259 if (!p_igetw(&tempMisc, f))
14260 {
14261 return qe_invalid;
14262 }
14263 tempguy.attributes[q] = tempMisc;
14264 }
14265
14266 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14267 {
14268 if(tempguy.type == eeWIZZ && !(tempguy.attributes[0]))
14269 tempguy.attributes[4] = 74;
14270 }
14271
14272 }
14273
14274
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetw(&(tempguy.bgsfx),f))
14275 {
14276 return qe_invalid;
14277 }
14278
14279
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetw(&(tempguy.bosspal),f))
14280 {
14281 return qe_invalid;
14282 }
14283
14284
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetw(&(tempguy.extend),f))
14285 {
14286 return qe_invalid;
14287 }
14288
14289 //! Enemy Defences
14290
14291 //If a 2.50 quest, use only the 2.5 defences.
14292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208896 times.
208896 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14293 {
14294
2/2
✓ Branch 0 taken 3969024 times.
✓ Branch 1 taken 208896 times.
4177920 for(int32_t j=0; j<edefLAST; j++)
14295 {
14296
1/2
✓ Branch 0 taken 3969024 times.
✗ Branch 1 not taken.
3969024 if(!p_getc(&(tempguy.defense[j]),f))
14297 {
14298 return qe_invalid;
14299 }
14300 3969024 }
14301 //then copy the generic script defence to all the new script defences
14302
14303 208896 }
14304
14305
14306
14307
14308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208896 times.
208896 if(guyversion >= 18)
14309 {
14310
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_getc(&(tempguy.hitsfx),f))
14311 {
14312 return qe_invalid;
14313 }
14314
14315
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_getc(&(tempguy.deadsfx),f))
14316 {
14317 return qe_invalid;
14318 }
14319 208896 }
14320
14321
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(guyversion >= 22)
14322 {
14323
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetl(&(tempguy.attributes[10]), f))
14324 {
14325 return qe_invalid;
14326 }
14327
14328
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetl(&(tempguy.attributes[11]),f))
14329 {
14330 return qe_invalid;
14331 }
14332 208896 }
14333 else if(guyversion >= 19)
14334 {
14335 int16_t tempMisc;
14336
14337 if(!p_igetw(&tempMisc,f))
14338 {
14339 return qe_invalid;
14340 }
14341
14342 tempguy.attributes[10] = tempMisc;
14343
14344 if(!p_igetw(&tempMisc,f))
14345 {
14346 return qe_invalid;
14347 }
14348
14349 tempguy.attributes[11] = tempMisc;
14350 }
14351
14352 //If a 2.54 or later quest, use all of the defences.
14353
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 106496 times.
208896 if(guyversion > 24) // Add new guyversion conditional statement
14354 {
14355
2/2
✓ Branch 0 taken 2342912 times.
✓ Branch 1 taken 106496 times.
2449408 for(int32_t j=edefLAST; j<edefLAST255; j++)
14356 {
14357
1/2
✓ Branch 0 taken 2342912 times.
✗ Branch 1 not taken.
2342912 if(!p_getc(&(tempguy.defense[j]),f))
14358 {
14359 return qe_invalid;
14360 }
14361 2342912 }
14362 106496 }
14363
14364
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 102400 times.
208896 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14365 {
14366
2/2
✓ Branch 0 taken 1024000 times.
✓ Branch 1 taken 102400 times.
1126400 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14367 {
14368 1024000 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14369 1024000 }
14370 102400 }
14371
14372 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14373
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 106496 times.
208896 if(guyversion > 25)
14374 {
14375
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.txsz),f))
14376 {
14377 return qe_invalid;
14378 }
14379
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.tysz),f))
14380 {
14381 return qe_invalid;
14382 }
14383
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.hxsz),f))
14384 {
14385 return qe_invalid;
14386 }
14387
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.hysz),f))
14388 {
14389 return qe_invalid;
14390 }
14391
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.hzsz),f))
14392 {
14393 return qe_invalid;
14394 }
14395 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14396
14397 */
14398 106496 }
14399 //More Enemy Editor vars for 2.60
14400
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 106496 times.
208896 if(guyversion > 26)
14401 {
14402
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.hxofs),f))
14403 {
14404 return qe_invalid;
14405 }
14406
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.hyofs),f))
14407 {
14408 return qe_invalid;
14409 }
14410
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.xofs),f))
14411 {
14412 return qe_invalid;
14413 }
14414
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.yofs),f))
14415 {
14416 return qe_invalid;
14417 }
14418
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.zofs),f))
14419 {
14420 return qe_invalid;
14421 }
14422 106496 }
14423
14424
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 102400 times.
208896 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14425 {
14426 102400 tempguy.wpnsprite = 0;
14427 102400 }
14428
14429
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 106496 times.
208896 if(guyversion > 27)
14430 {
14431
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.wpnsprite),f))
14432 {
14433 return qe_invalid;
14434 }
14435 106496 }
14436
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 102400 times.
208896 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14437 {
14438 102400 tempguy.SIZEflags = 0;
14439 102400 }
14440
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 106496 times.
208896 if(guyversion > 28)
14441 {
14442
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.SIZEflags),f))
14443 {
14444 return qe_invalid;
14445 }
14446
14447 106496 }
14448
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 102400 times.
208896 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14449 {
14450 102400 tempguy.frozentile = 0;
14451 102400 tempguy.frozencset = 0;
14452 102400 tempguy.frozenclock = 0;
14453
2/2
✓ Branch 0 taken 1024000 times.
✓ Branch 1 taken 102400 times.
1126400 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14454 102400 }
14455
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 106496 times.
208896 if(guyversion >= 30)
14456 {
14457
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.frozentile),f))
14458 {
14459 return qe_invalid;
14460 }
14461
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.frozencset),f))
14462 {
14463 return qe_invalid;
14464 }
14465
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.frozenclock),f))
14466 {
14467 return qe_invalid;
14468 }
14469
2/2
✓ Branch 0 taken 1064960 times.
✓ Branch 1 taken 106496 times.
1171456 for ( int32_t q = 0; q < 10; q++ ) {
14470
1/2
✓ Branch 0 taken 1064960 times.
✗ Branch 1 not taken.
1064960 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14471 {
14472 return qe_invalid;
14473 }
14474 1064960 }
14475
14476 106496 }
14477
14478
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 106496 times.
208896 if(guyversion >= 34)
14479 {
14480
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetw(&(tempguy.firesfx),f))
14481 {
14482 return qe_invalid;
14483 }
14484
2/2
✓ Branch 0 taken 1810432 times.
✓ Branch 1 taken 106496 times.
1916928 for(int q=15;q<32;++q)
14485 {
14486
1/2
✓ Branch 0 taken 1810432 times.
✗ Branch 1 not taken.
1810432 if(!p_igetl(&(tempguy.attributes[q]),f))
14487 {
14488 return qe_invalid;
14489 }
14490 1810432 }
14491
14492
2/2
✓ Branch 0 taken 3407872 times.
✓ Branch 1 taken 106496 times.
3514368 for ( int32_t q = 0; q < 32; q++ ) {
14493
1/2
✓ Branch 0 taken 3407872 times.
✗ Branch 1 not taken.
3407872 if(!p_igetl(&(tempguy.movement[q]),f))
14494 {
14495 return qe_invalid;
14496 }
14497 3407872 }
14498
2/2
✓ Branch 0 taken 3407872 times.
✓ Branch 1 taken 106496 times.
3514368 for ( int32_t q = 0; q < 32; q++ ) {
14499
1/2
✓ Branch 0 taken 3407872 times.
✗ Branch 1 not taken.
3407872 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14500 {
14501 return qe_invalid;
14502 }
14503 3407872 }
14504
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetw(&(tempguy.script),f))
14505 {
14506 return qe_invalid;
14507 }
14508
2/2
✓ Branch 0 taken 851968 times.
✓ Branch 1 taken 106496 times.
958464 for ( int32_t q = 0; q < 8; q++ )
14509 {
14510
1/2
✓ Branch 0 taken 851968 times.
✗ Branch 1 not taken.
851968 if(!p_igetl(&(tempguy.initD[q]),f))
14511 {
14512 return qe_invalid;
14513 }
14514 851968 }
14515
2/2
✓ Branch 0 taken 212992 times.
✓ Branch 1 taken 106496 times.
319488 for ( int32_t q = 0; q < 2; q++ )
14516 {
14517 int32_t temp;
14518
1/2
✓ Branch 0 taken 212992 times.
✗ Branch 1 not taken.
212992 if(!p_igetl(&temp,f))
14519 {
14520 return qe_invalid;
14521 }
14522 212992 }
14523
14524 106496 }
14525
14526
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 106496 times.
208896 if(guyversion >= 37)
14527 {
14528
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.editorflags),f))
14529 {
14530 return qe_invalid;
14531 }
14532 106496 }
14533
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 102400 times.
208896 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14534
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 106496 times.
208896 if(guyversion >= 38)
14535 {
14536
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.attributes[12]),f))
14537 {
14538 return qe_invalid;
14539 }
14540
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.attributes[13]),f))
14541 {
14542 return qe_invalid;
14543 }
14544
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_igetl(&(tempguy.attributes[14]),f))
14545 {
14546 return qe_invalid;
14547 }
14548
14549 106496 }
14550
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 102400 times.
208896 if ( guyversion < 38 )
14551 {
14552 102400 tempguy.attributes[12] = 0;
14553 102400 tempguy.attributes[13] = 0;
14554 102400 tempguy.attributes[14] = 0;
14555 102400 }
14556
14557
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 106496 times.
208896 if ( guyversion >= 39 )
14558 {
14559
2/2
✓ Branch 0 taken 851968 times.
✓ Branch 1 taken 106496 times.
958464 for ( int32_t q = 0; q < 8; q++ )
14560 {
14561
2/2
✓ Branch 0 taken 55377920 times.
✓ Branch 1 taken 851968 times.
56229888 for ( int32_t w = 0; w < 65; w++ )
14562 {
14563
1/2
✓ Branch 0 taken 55377920 times.
✗ Branch 1 not taken.
55377920 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14564 {
14565 return qe_invalid;
14566 }
14567 55377920 }
14568
2/2
✓ Branch 0 taken 643072 times.
✓ Branch 1 taken 208896 times.
851968 if(guyversion < 54)
14569 {
14570 byte dummybyte;
14571
2/2
✓ Branch 0 taken 13578240 times.
✓ Branch 1 taken 208896 times.
13787136 for ( int32_t w = 0; w < 65; w++ )
14572
1/2
✓ Branch 0 taken 13578240 times.
✗ Branch 1 not taken.
13578240 if(!p_getc(&dummybyte,f))
14573 return qe_invalid;
14574 208896 }
14575 851968 }
14576
14577
14578 106496 }
14579
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 102400 times.
208896 if ( guyversion < 39 ) //apply old InitD strings to both
14580 {
14581
2/2
✓ Branch 0 taken 819200 times.
✓ Branch 1 taken 102400 times.
921600 for ( int32_t q = 0; q < 8; q++ )
14582 {
14583 819200 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14584 819200 }
14585 102400 }
14586
4/4
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 102400 times.
✓ Branch 2 taken 80384 times.
✓ Branch 3 taken 26112 times.
208896 if ( guyversion >= 40 && guyversion < 54)
14587
1/2
✓ Branch 0 taken 26112 times.
✗ Branch 1 not taken.
26112 if(!p_igetw(&(tempguy.weap_data.script),f))
14588 return qe_invalid;
14589
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 102400 times.
208896 if ( guyversion < 40 )
14590 102400 tempguy.weap_data.script = 0;
14591 //eweapon script InitD
14592
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 106496 times.
208896 if ( guyversion >= 41 )
14593 {
14594
2/2
✓ Branch 0 taken 80384 times.
✓ Branch 1 taken 26112 times.
106496 if(guyversion < 54)
14595
2/2
✓ Branch 0 taken 208896 times.
✓ Branch 1 taken 26112 times.
235008 for ( int32_t q = 0; q < 8; q++ )
14596
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(!p_igetl(&(tempguy.weap_data.initd[q]),f))
14597 26112 return qe_invalid;
14598
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if ( guy_cversion < 4 )
14599 {
14600 if ( tempguy.type == eeKEESE )
14601 {
14602
14603 if ( !tempguy.attributes[0] )
14604 {
14605 tempguy.attributes[15] = 120;
14606 tempguy.attributes[16] = 16;
14607
14608 }
14609 }
14610 if ( tempguy.type == eePEAHAT )
14611 {
14612 tempguy.attributes[15] = 80;
14613 tempguy.attributes[16] = 16;
14614 }
14615
14616 if ( tempguy.type == eeGHINI )
14617 {
14618 tempguy.attributes[15] = 120;
14619 tempguy.attributes[16] = 10;
14620 }
14621
14622 }
14623 106496 }
14624
14625
14626
14627 //default weapon sprites (quest version < 2.54)
14628 //port over old defaults -Z
14629
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 102400 times.
208896 if(guyversion < 32)
14630 {
14631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102400 times.
102400 if ( tempguy.wpnsprite <= 0 )
14632 {
14633
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2849 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86878 times.
✓ Branch 4 taken 801 times.
✓ Branch 5 taken 691 times.
✓ Branch 6 taken 1900 times.
✓ Branch 7 taken 1291 times.
✓ Branch 8 taken 2399 times.
✓ Branch 9 taken 206 times.
✓ Branch 10 taken 77 times.
✓ Branch 11 taken 448 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 906 times.
✓ Branch 14 taken 1802 times.
✓ Branch 15 taken 229 times.
✓ Branch 16 taken 325 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1519 times.
102400 switch(tempguy.weapon)
14634 {
14635 case wNone:
14636 86878 tempguy.wpnsprite = 0; break;
14637
14638 case wSword:
14639 case wBeam:
14640 case wBrang:
14641 case wBomb:
14642 case wSBomb:
14643 case wLitBomb:
14644 case wLitSBomb:
14645 case wArrow:
14646 case wFire:
14647 case wWhistle:
14648 case wBait:
14649 case wWand:
14650 case wMagic:
14651 case wCatching:
14652 case wWind:
14653 case wRefMagic:
14654 case wRefFireball:
14655 case wRefRock:
14656 case wHammer:
14657 case wHookshot:
14658 case wHSHandle:
14659 case wHSChain:
14660 case wSSparkle:
14661 case wFSparkle:
14662 case wSmack:
14663 case wPhantom:
14664 case wCByrna:
14665 case wRefBeam:
14666 case wStomp:
14667 case lwMax:
14668 case wScript1:
14669 case wScript2:
14670 case wScript3:
14671 case wScript4:
14672 case wScript5:
14673 case wScript6:
14674 case wScript7:
14675 case wScript8:
14676 case wScript9:
14677 case wScript10:
14678 case wIce:
14679 //Cannot use any of these weapons yet.
14680 tempguy.wpnsprite = -1;
14681 break;
14682
14683 case wEnemyWeapons:
14684 2849 case ewFireball: tempguy.wpnsprite = 17; break;
14685
14686 801 case ewArrow: tempguy.wpnsprite = 19; break;
14687 691 case ewBrang: tempguy.wpnsprite = 4; break;
14688 1900 case ewSword: tempguy.wpnsprite = 20; break;
14689 1291 case ewRock: tempguy.wpnsprite = 18; break;
14690 2399 case ewMagic: tempguy.wpnsprite = 21; break;
14691 206 case ewBomb: tempguy.wpnsprite = 78; break;
14692 77 case ewSBomb: tempguy.wpnsprite = 79; break;
14693 448 case ewLitBomb: tempguy.wpnsprite = 76; break;
14694 79 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14695 906 case ewFireTrail: tempguy.wpnsprite = 80; break;
14696 1802 case ewFlame: tempguy.wpnsprite = 35; break;
14697 229 case ewWind: tempguy.wpnsprite = 36; break;
14698 325 case ewFlame2: tempguy.wpnsprite = 81; break;
14699 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14700 case ewIce: tempguy.wpnsprite = 83; break;
14701 1519 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14702
14703
14704 default: break; //No assign.
14705 }
14706 102400 }
14707 102400 }
14708
14709 //default weapon fire sound (quest version < 2.54)
14710 //port over old defaults and zero new data. -Z
14711
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 102400 times.
208896 if(guyversion < 34)
14712 {
14713
2/2
✓ Branch 0 taken 3276800 times.
✓ Branch 1 taken 102400 times.
3379200 for ( int32_t q = 0; q < 32; q++ )
14714 {
14715 3276800 tempguy.movement[q] = 0;
14716 3276800 tempguy.new_weapon[q] = 0;
14717
14718 3276800 }
14719
14720 //NPC Script attributes.
14721 102400 tempguy.script = 0; //No scripted enemies existed. -Z
14722
2/2
✓ Branch 0 taken 819200 times.
✓ Branch 1 taken 102400 times.
921600 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14723
14724
2/2
✓ Branch 0 taken 1740800 times.
✓ Branch 1 taken 102400 times.
1843200 for ( int32_t q = 15; q < 32; q++) tempguy.attributes[q] = 0; //misc 16-32
14725
14726 //old default sounds
14727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102400 times.
102400 if ( tempguy.firesfx <= 0 )
14728 {
14729
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2849 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 86878 times.
✓ Branch 4 taken 801 times.
✓ Branch 5 taken 691 times.
✓ Branch 6 taken 1900 times.
✓ Branch 7 taken 1291 times.
✓ Branch 8 taken 2399 times.
✓ Branch 9 taken 206 times.
✓ Branch 10 taken 77 times.
✓ Branch 11 taken 448 times.
✓ Branch 12 taken 79 times.
✓ Branch 13 taken 906 times.
✓ Branch 14 taken 1802 times.
✓ Branch 15 taken 229 times.
✓ Branch 16 taken 325 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1519 times.
102400 switch(tempguy.weapon)
14730 {
14731 case wNone:
14732 86878 tempguy.firesfx = 0; break;
14733
14734 case wSword:
14735 case wBeam:
14736 case wBrang:
14737 case wBomb:
14738 case wSBomb:
14739 case wLitBomb:
14740 case wLitSBomb:
14741 case wArrow:
14742 case wFire:
14743 case wWhistle:
14744 case wBait:
14745 case wWand:
14746 case wMagic:
14747 case wCatching:
14748 case wWind:
14749 case wRefMagic:
14750 case wRefFireball:
14751 case wRefRock:
14752 case wHammer:
14753 case wHookshot:
14754 case wHSHandle:
14755 case wHSChain:
14756 case wSSparkle:
14757 case wFSparkle:
14758 case wSmack:
14759 case wPhantom:
14760 case wCByrna:
14761 case wRefBeam:
14762 case wStomp:
14763 case lwMax:
14764 case wScript1:
14765 case wScript2:
14766 case wScript3:
14767 case wScript4:
14768 case wScript5:
14769 case wScript6:
14770 case wScript7:
14771 case wScript8:
14772 case wScript9:
14773 case wScript10:
14774 case wIce:
14775 //Cannot use any of these weapons yet.
14776 tempguy.firesfx = -1;
14777 break;
14778
14779 case wEnemyWeapons:
14780 2849 case ewFireball: tempguy.firesfx = 40; break;
14781
14782 801 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14783 691 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14784 1900 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14785 1291 case ewRock: tempguy.firesfx = 51; break;
14786 2399 case ewMagic: tempguy.firesfx = 32; break;
14787 206 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14788 77 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14789 448 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14790 79 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14791 906 case ewFireTrail: tempguy.firesfx = 13; break;
14792 1802 case ewFlame: tempguy.firesfx = 13; break;
14793 229 case ewWind: tempguy.firesfx = 32; break;
14794 325 case ewFlame2: tempguy.firesfx = 13; break;
14795 case ewFlame2Trail: tempguy.firesfx = 13; break;
14796 case ewIce: tempguy.firesfx = 44; break;
14797 1519 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14798
14799 //what about special attacks (e.g. summoning == 56)
14800 default: break; //No assign.
14801 }
14802 102400 }
14803 102400 }
14804
14805 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14806
4/6
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 102400 times.
✓ Branch 2 taken 106496 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 106496 times.
208896 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14807 {
14808
2/2
✓ Branch 0 taken 89799 times.
✓ Branch 1 taken 12601 times.
102400 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14809 102400 }
14810 //Keese and bat halt rates.
14811
3/4
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 106496 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102400 times.
208896 if ( guyversion < 42 && guy_cversion < 4 )
14812 {
14813
14814
2/2
✓ Branch 0 taken 101101 times.
✓ Branch 1 taken 1299 times.
102400 if ( tempguy.type == eeKEESE )
14815 {
14816
14817
2/2
✓ Branch 0 taken 935 times.
✓ Branch 1 taken 364 times.
1299 if ( !tempguy.attributes[0] )
14818 {
14819 935 tempguy.attributes[15] = 120;
14820 935 tempguy.attributes[16] = 16;
14821
14822 935 }
14823 1299 }
14824
2/2
✓ Branch 0 taken 101935 times.
✓ Branch 1 taken 465 times.
102400 if ( tempguy.type == eePEAHAT )
14825 {
14826 465 tempguy.attributes[15] = 80;
14827 465 tempguy.attributes[16] = 16;
14828 465 }
14829
2/2
✓ Branch 0 taken 102200 times.
✓ Branch 1 taken 200 times.
102400 if ( tempguy.type == eeGHINI )
14830 {
14831 200 tempguy.attributes[15] = 120;
14832 200 tempguy.attributes[16] = 10;
14833 200 }
14834
14835
14836 102400 }
14837
14838
14839 //miscellaneous other corrections
14840 //fix the mirror wizzrobe -DD
14841
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(guyversion < 7)
14842 {
14843 if(i == eMWIZ)
14844 {
14845 tempguy.attributes[1] = 0;
14846 tempguy.attributes[3] = 1;
14847 }
14848 }
14849
14850
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(guyversion < 8)
14851 {
14852 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14853 {
14854 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14855 tempguy.attributes[4] = 4; //neck length in segments
14856 tempguy.attributes[5] = 8; //neck offset from first body tile
14857 tempguy.attributes[6] = 40; //offset for each subsequent neck tile from the first neck tile
14858 tempguy.attributes[7] = 168; //head offset from first body tile
14859 tempguy.attributes[8] = 228; //flying head offset from first body tile
14860
14861 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14862 {
14863 tempguy.attributes[5] += 10; //neck offset from first body tile
14864 tempguy.attributes[7] -= 12; //head offset from first body tile
14865 }
14866 }
14867 }
14868
14869
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14870 {
14871 if(get_bit(deprecated_rules,46) && tempguy.type==eeDONGO && tempguy.attributes[0]==0)
14872 tempguy.bosspal = spDIG;
14873 }
14874
14875
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(guyversion < 11) // December 2007 - Spinning Tile fix
14876 {
14877 if(tempguy.type==eeSPINTILE)
14878 {
14879 tempguy.flags |= guy_superman;
14880 tempguy.item_set = 0; // Don't drop items
14881 tempguy.step = 300;
14882 }
14883 }
14884
14885
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14886 {
14887 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14888 {
14889 if(tempguy.type==eeROPE)
14890 {
14891 tempguy.flags &= ~guy_flashing;
14892 }
14893 }
14894
14895 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14896 {
14897 if(tempguy.type==eeBUBBLE)
14898 {
14899 tempguy.flags &= ~guy_flashing;
14900 }
14901 }
14902
14903 if((tempguy.type==eeGHINI)&&(tempguy.attributes[0]))
14904 {
14905 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14906 {
14907 tempguy.flags |= guy_blinking;
14908 }
14909
14910 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14911 {
14912 tempguy.flags |= guy_transparent;
14913 }
14914 }
14915 }
14916
14917
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14918 {
14919 if(i==gFIRE)
14920 {
14921 tempguy.e_anim = aFLIP;
14922 tempguy.e_frate = 24;
14923 }
14924
14925 if(i==gFAIRY)
14926 {
14927 tempguy.e_anim = a2FRM;
14928 tempguy.e_frate = 16;
14929 }
14930 }
14931
14932
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14933 {
14934 if(i==0) Z_message("Updating guys to version 16...\n");
14935
14936 update_guy_1(&tempguy);
14937
14938 if(i==eMPOLSV)
14939 {
14940 tempguy.defense[edefARROW] = edCHINK;
14941 tempguy.defense[edefMAGIC] = ed1HKO;
14942 tempguy.defense[edefREFMAGIC] = ed1HKO;
14943 }
14944 }
14945
14946
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(guyversion < 17) // December 2009
14947 {
14948 if(tempguy.type==eePROJECTILE)
14949 {
14950 tempguy.attributes[0] = 0;
14951 }
14952 }
14953
14954
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(guyversion < 18) // January 2010
14955 {
14956 bool boss = (tempguy.type == eeAQUA || tempguy.type==eeDONGO || tempguy.type == eeMANHAN || tempguy.type == eeGHOMA || tempguy.type==eeDIG
14957 || tempguy.type == eeGLEEOK || tempguy.type==eePATRA || tempguy.type == eeGANON || tempguy.type==eeMOLD);
14958
14959 tempguy.hitsfx = (boss && tempguy.type != eeMOLD && tempguy.type != eeDONGO && tempguy.type != eeDIG) ? WAV_GASP : 0;
14960 tempguy.deadsfx = (boss && (tempguy.type != eeDIG || tempguy.attributes[9] == 0)) ? WAV_GASP : WAV_EDEAD;
14961
14962 if(tempguy.type == eeAQUA)
14963 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14964 else if(tempguy.type == eeMANHAN)
14965 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
14966 else if(tempguy.type==eePATRA)
14967 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14968 else if(tempguy.type==eeGHOMA)
14969 {
14970 for(int32_t j=0; j<edefLAST; j++)
14971 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
14972
14973 tempguy.defense[edefARROW] = ((tempguy.attributes[0]==3) ? edCHINKL8 : (tempguy.attributes[0]==2) ? edCHINKL4 : 0);
14974
14975 if(tempguy.attributes[0]==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
14976
14977 tempguy.attributes[0]--;
14978 }
14979 else if(tempguy.type == eeGLEEOK)
14980 {
14981 for(int32_t j=0; j<edefLAST; j++)
14982 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14983
14984 if(tempguy.attributes[2]==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
14985 }
14986 else if(tempguy.type == eeARMOS)
14987 {
14988 tempguy.type=eeWALK;
14989 tempguy.hrate = 0;
14990 tempguy.attributes[9] = tempguy.attributes[0];
14991 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
14992 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
14993 tempguy.attributes[8] = e9tARMOS;
14994 }
14995 else if(tempguy.type == eeGHINI && !tempguy.attributes[0])
14996 {
14997 tempguy.type=eeWALK;
14998 tempguy.hrate = 0;
14999 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] =
15000 tempguy.attributes[6] = tempguy.attributes[7] = tempguy.attributes[8] = tempguy.attributes[9] = 0;
15001 }
15002
15003 // Spawn animation flags
15004 if(tempguy.type == eeWALK && (tempguy.flags&guy_armos || tempguy.flags&guy_ghini))
15005 tempguy.flags |= guy_fade_flicker;
15006 else
15007 tempguy.flags &= (guy_flags)0x0F00000F; // Get rid of the unused flags!
15008 }
15009
15010
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(guyversion < 20) // April 2010
15011 {
15012 if(tempguy.type == eeTRAP)
15013 {
15014 tempguy.attributes[1] = tempguy.attributes[9];
15015
15016 if(tempguy.attributes[9]>=1)
15017 {
15018 tempguy.attributes[0]++;
15019 }
15020
15021 tempguy.attributes[9] = 0;
15022 }
15023
15024 // Bomb Blast fix
15025 if(tempguy.weapon==ewBomb && tempguy.type!=eeROPE && (tempguy.type!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
15026 tempguy.weapon = ewLitBomb;
15027 else if(tempguy.weapon==ewSBomb && tempguy.type!=eeROPE && (tempguy.type!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
15028 tempguy.weapon = ewLitSBomb;
15029 }
15030
15031
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(guyversion < 21) // September 2011
15032 {
15033 if(tempguy.type == eeKEESE || tempguy.type == eeKEESETRIB)
15034 {
15035 if(tempguy.type == eeKEESETRIB)
15036 {
15037 tempguy.type = eeKEESE;
15038 tempguy.attributes[1] = e2tKEESETRIB;
15039 tempguy.attributes[0] = 0;
15040 }
15041
15042 tempguy.rate = 2;
15043 tempguy.hrate = 8;
15044 tempguy.homing = 0;
15045 tempguy.step= (tempguy.type == eeKEESE && tempguy.attributes[0] ? 100:62);
15046 }
15047 else if(tempguy.type == eePEAHAT || tempguy.type==eePATRA)
15048 {
15049 if(tempguy.type == eePEAHAT)
15050 {
15051 tempguy.rate = 4;
15052 tempguy.step = 62;
15053 }
15054 else
15055 tempguy.step = 25;
15056
15057 tempguy.hrate = 8;
15058 tempguy.homing = 0;
15059 }
15060 else if(tempguy.type == eeDIG || tempguy.type == eeMANHAN)
15061 {
15062 if(tempguy.type == eeMANHAN)
15063 tempguy.step=50;
15064
15065 tempguy.hrate = 16;
15066 tempguy.homing = 0;
15067 }
15068 else if(tempguy.type == eeGLEEOK)
15069 {
15070 tempguy.rate = 2;
15071 tempguy.homing = 0;
15072 tempguy.hrate = 9;
15073 tempguy.step=89;
15074 }
15075 else if(tempguy.type == eeGHINI)
15076 {
15077 tempguy.rate = 4;
15078 tempguy.hrate = 12;
15079 tempguy.step=62;
15080 tempguy.homing = 0;
15081 }
15082
15083 // Bigdig random rate fix
15084 if(tempguy.type==eeDIG && tempguy.attributes[9]==1)
15085 {
15086 tempguy.rate = 2;
15087 }
15088 }
15089
15090
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(guyversion < 24) // November 2012
15091 {
15092 if(tempguy.type==eeLANM)
15093 tempguy.attributes[2] = 1;
15094 else if(tempguy.type==eeMOLD)
15095 tempguy.attributes[1] = 0;
15096 }
15097
15098
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 102400 times.
208896 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15099 {
15100
2/2
✓ Branch 0 taken 1400 times.
✓ Branch 1 taken 101000 times.
102400 if(tempguy.type!=eeDIG)
15101 {
15102 101000 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15103 101000 }
15104
15105 102400 }
15106 // does not seem to solve the issue!
15107
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if ( Header->zelda_version <= 0x210 )
15108 {
15109 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15110 if ( tempguy.type == eeDONGO )
15111 {
15112 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15113 }
15114 }
15115
15116
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 102400 times.
208896 if(guyversion >= 42)
15117 {
15118
2/2
✓ Branch 0 taken 103936 times.
✓ Branch 1 taken 2560 times.
106496 if(guyversion >= 47)
15119 {
15120
1/2
✓ Branch 0 taken 103936 times.
✗ Branch 1 not taken.
103936 if(!p_igetl(&(tempguy.moveflags),f))
15121 {
15122 return qe_invalid;
15123 }
15124 103936 }
15125 else
15126 {
15127 byte fl;
15128
1/2
✓ Branch 0 taken 2560 times.
✗ Branch 1 not taken.
2560 if(!p_getc(&fl,f))
15129 {
15130 return qe_invalid;
15131 }
15132 2560 tempguy.moveflags = (move_flags)fl;
15133 }
15134 106496 }
15135 else
15136 {
15137
7/8
✓ Branch 0 taken 3056 times.
✓ Branch 1 taken 80670 times.
✓ Branch 2 taken 2717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 958 times.
✓ Branch 5 taken 642 times.
✓ Branch 6 taken 498 times.
✓ Branch 7 taken 13859 times.
102400 switch(tempguy.type)
15138 {
15139 //No gravity; floats over pits
15140 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15141 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15142 //Special (bosses, etc)
15143 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15144 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15145 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15146 80670 tempguy.moveflags = move_can_pitwalk;
15147 80670 break;
15148 //No gravity, but falls in pits
15149 case eeLEV:
15150 958 tempguy.moveflags = move_can_pitfall;
15151 958 break;
15152 //Bosses that respect pits
15153 case eeDONGO:
15154 642 tempguy.moveflags = move_obeys_grav;
15155 642 break;
15156 case eeLANM:
15157 498 tempguy.moveflags = move_none;
15158 498 break;
15159 //Gravity, floats over pits
15160 case eeWIZZ: case eeWALLM: case eeGHINI:
15161 2717 tempguy.moveflags = move_obeys_grav | move_can_pitwalk;
15162 2717 break;
15163 //Gravity and falls in pits
15164 case eeWALK:
15165
4/4
✓ Branch 0 taken 13164 times.
✓ Branch 1 taken 695 times.
✓ Branch 2 taken 529 times.
✓ Branch 3 taken 12635 times.
13859 if (tempguy.attributes[8]==e9tPOLSVOICE||tempguy.attributes[8]==e9tVIRE)
15166 1224 break;
15167 [[fallthrough]];
15168 case eeOTHER:
15169 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15170 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15171 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15172 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15173 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15174 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15175 15691 tempguy.moveflags = move_obeys_grav | move_can_pitfall;
15176 15691 }
15177 }
15178
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 102400 times.
208896 if(guyversion < 43)
15179 {
15180
2/2
✓ Branch 0 taken 83387 times.
✓ Branch 1 taken 19013 times.
102400 switch(tempguy.type)
15181 {
15182 //No gravity; floats over pits
15183 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15184 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15185 //Special (bosses, etc)
15186 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15187 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15188 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15189 case eeWIZZ: case eeWALLM: case eeGHINI:
15190 //Gravity, floats over pits
15191 83387 tempguy.moveflags |= move_can_waterwalk;
15192 83387 tempguy.moveflags |= move_can_pitwalk;
15193 83387 break;
15194 }
15195 102400 }
15196
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 102400 times.
208896 if (guyversion < 44)
15197 {
15198
2/2
✓ Branch 0 taken 101487 times.
✓ Branch 1 taken 913 times.
102400 if ( tempguy.type == eeGHOMA )
15199 {
15200 913 tempguy.flags |= guy_fade_instant;
15201 913 }
15202 102400 }
15203
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 102400 times.
208896 if (guyversion > 44)
15204 {
15205
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_getc(&(tempguy.spr_shadow),f))
15206 {
15207 return qe_invalid;
15208 }
15209
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_getc(&(tempguy.spr_death),f))
15210 {
15211 return qe_invalid;
15212 }
15213
1/2
✓ Branch 0 taken 106496 times.
✗ Branch 1 not taken.
106496 if(!p_getc(&(tempguy.spr_spawn),f))
15214 {
15215 return qe_invalid;
15216 }
15217 106496 }
15218 else
15219 {
15220
2/2
✓ Branch 0 taken 102003 times.
✓ Branch 1 taken 397 times.
102400 tempguy.spr_shadow = (tempguy.type==eeROCK && tempguy.attributes[9]==1) ? iwLargeShadow : iwShadow;
15221 102400 tempguy.spr_death = iwDeath;
15222 102400 tempguy.spr_spawn = iwSpawn;
15223 }
15224
15225
2/2
✓ Branch 0 taken 106496 times.
✓ Branch 1 taken 102400 times.
208896 if(guyversion < 46)
15226 {
15227
4/4
✓ Branch 0 taken 13859 times.
✓ Branch 1 taken 88541 times.
✓ Branch 2 taken 13164 times.
✓ Branch 3 taken 695 times.
102400 if(tempguy.type == eeWALK && tempguy.attributes[8] == e9tPOLSVOICE)
15228 {
15229 695 tempguy.moveflags |= move_can_waterwalk;
15230 695 }
15231 102400 }
15232
15233
2/2
✓ Branch 0 taken 103936 times.
✓ Branch 1 taken 104960 times.
208896 if (guyversion < 47)
15234 {
15235
4/4
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 103530 times.
✓ Branch 2 taken 856 times.
✓ Branch 3 taken 574 times.
104960 if (tempguy.type == eeDIG && tempguy.attributes[9]!=1)
15236 {
15237 574 tempguy.flags |= guy_ignore_kill_all;
15238 574 }
15239 104960 }
15240
15241
2/2
✓ Branch 0 taken 83456 times.
✓ Branch 1 taken 125440 times.
208896 if (guyversion < 49)
15242 {
15243
8/8
✓ Branch 0 taken 16388 times.
✓ Branch 1 taken 109052 times.
✓ Branch 2 taken 15916 times.
✓ Branch 3 taken 472 times.
✓ Branch 4 taken 15433 times.
✓ Branch 5 taken 483 times.
✓ Branch 6 taken 528 times.
✓ Branch 7 taken 14905 times.
125440 if (tempguy.type == eeWALK && (tempguy.attributes[6]==e7tPERMJINX || tempguy.attributes[6]==e7tTEMPJINX || tempguy.attributes[6]==e7tUNJINX)) //BUBBLE CHECK
15244 {
15245
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 710 times.
✓ Branch 2 taken 712 times.
✓ Branch 3 taken 61 times.
1483 switch (tempguy.attributes[7]) {
15246 case 0: //Sword
15247 710 tempguy.attributes[7] = e8tSWORD;
15248 710 break;
15249 case 1: //Item
15250 712 tempguy.attributes[7] = e8tITEM;
15251 712 break;
15252 case 2: //Both
15253 61 tempguy.attributes[7] = e8tSWORD|e8tITEM;
15254 61 break;
15255 default: //this can actually happen since Misc8 can be set to any number.
15256 tempguy.attributes[7] = 0;
15257 break;
15258 }
15259 1483 }
15260 125440 }
15261
15262 //these could possible be combined but rather be safe...
15263
2/2
✓ Branch 0 taken 83456 times.
✓ Branch 1 taken 125440 times.
208896 if (guyversion < 51) //reimport the firesfx, zoria ducked up.
15264 {
15265 125440 guy_update_firesfx(tempguy);
15266 125440 }
15267
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 83456 times.
208896 if (guyversion < 52)
15268 {
15269 125440 guy_update_weaponflags(tempguy);
15270 125440 }
15271
2/2
✓ Branch 0 taken 80384 times.
✓ Branch 1 taken 3072 times.
83456 else if(guyversion < 54)
15272 {
15273
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_getc(&(tempguy.weap_data.unblockable), f))
15274 return qe_invalid;
15275
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.moveflags), f))
15276 return qe_invalid;
15277
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.override_flags), f))
15278 return qe_invalid;
15279
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.tilew), f))
15280 return qe_invalid;
15281
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.tileh), f))
15282 return qe_invalid;
15283
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.hxsz), f))
15284 return qe_invalid;
15285
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.hysz), f))
15286 return qe_invalid;
15287
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.hzsz), f))
15288 return qe_invalid;
15289
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.hxofs), f))
15290 return qe_invalid;
15291
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.hyofs), f))
15292 return qe_invalid;
15293
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.xofs), f))
15294 return qe_invalid;
15295
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&(tempguy.weap_data.yofs), f))
15296 return qe_invalid;
15297 int32_t temp_step;
15298
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if (!p_igetl(&temp_step, f))
15299 return qe_invalid;
15300 3072 tempguy.weap_data.step = zslongToFix(temp_step*100);
15301
2/2
✓ Branch 0 taken 15360 times.
✓ Branch 1 taken 3072 times.
18432 for (int32_t q = 0; q < WPNSPR_MAX; ++q)
15302 {
15303
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if (!p_igetw(&(tempguy.weap_data.burnsprs[q]), f))
15304 return qe_invalid;
15305
1/2
✓ Branch 0 taken 15360 times.
✗ Branch 1 not taken.
15360 if (!p_igetw(&(tempguy.weap_data.light_rads[q]), f))
15306 return qe_invalid;
15307 15360 }
15308 3072 }
15309
2/2
✓ Branch 0 taken 125440 times.
✓ Branch 1 taken 83456 times.
208896 if (guyversion < 53)
15310 {
15311 125440 guy_update_weaponspecialsfx(tempguy);
15312 125440 }
15313 else
15314 {
15315
1/2
✓ Branch 0 taken 83456 times.
✗ Branch 1 not taken.
83456 if (!p_getc(&(tempguy.specialsfx), f))
15316 return qe_invalid;
15317 }
15318
15319
2/2
✓ Branch 0 taken 80384 times.
✓ Branch 1 taken 128512 times.
208896 if(guyversion >= 54)
15320 {
15321
1/2
✓ Branch 0 taken 80384 times.
✗ Branch 1 not taken.
80384 if(auto ret = read_weap_data(tempguy.weap_data, f))
15322 return ret;
15323 80384 }
15324 else
15325 {
15326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128512 times.
128512 SETFLAG(tempguy.weap_data.wflags, WFLAG_UPDATE_IGNITE_SPRITE, tempguy.flags & guy_burning_sprites);
15327 128512 tempguy.weap_data.flags |= wdata_set_step;
15328
2/2
✓ Branch 0 taken 126931 times.
✓ Branch 1 taken 1581 times.
128512 if(tempguy.weapon == ewRock)
15329 1581 tempguy.weap_data.wflags |= WFLAG_BREAK_ON_SOLID;
15330 }
15331
15332
1/2
✓ Branch 0 taken 208896 times.
✗ Branch 1 not taken.
208896 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
15333 {
15334 tempguy.script = 0;
15335 for(int q = 0; q < 8; ++q)
15336 tempguy.initD[q] = 0;
15337 }
15338 208896 guysbuf[i] = tempguy;
15339 208896 }
15340 408 }
15341
15342 408 return 0;
15343 490 }
15344
15345 void update_guy_1(guydata *tempguy) // November 2009
15346 {
15347 bool doesntcount = false;
15348 tempguy->flags &= ~guy_weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15349
15350 switch(tempguy->type)
15351 {
15352 case 1: //eeWALK
15353 switch(tempguy->attributes[9])
15354 {
15355 case 0: //Stalfos
15356 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15357 tempguy->attributes[0]=4;
15358
15359 break;
15360
15361 case 1: //Darknut
15362 goto darknuts;
15363 break;
15364 }
15365
15366 tempguy->attributes[9] = 0;
15367 break;
15368
15369 case 2: //eeSHOOT
15370 tempguy->type = eeWALK;
15371
15372 switch(tempguy->attributes[9])
15373 {
15374 case 0: //Octorok
15375 if(tempguy->attributes[0]==1||tempguy->attributes[0]==2)
15376 {
15377 tempguy->attributes[0]=e1tFIREOCTO;
15378 tempguy->attributes[1]=e2tFIREOCTO;
15379 }
15380 else tempguy->attributes[0] = 0;
15381
15382 tempguy->attributes[5]=tempguy->attributes[3];
15383 tempguy->attributes[3]=tempguy->attributes[2];
15384 tempguy->attributes[2]=0;
15385 break;
15386
15387 case 1: // Moblin
15388 tempguy->attributes[0] = 0;
15389 break;
15390
15391 case 2: //Lynel
15392 tempguy->attributes[5]=tempguy->attributes[0]+1;
15393 tempguy->attributes[0]=0;
15394 break;
15395
15396 case 3: //Stalfos 2
15397 if(tempguy->attributes[0]==1) // Fires four projectiles at once
15398 tempguy->attributes[0]=e1t4SHOTS;
15399 else tempguy->attributes[0] = 0;
15400
15401 break;
15402
15403 case 4: //Darknut 5
15404 darknuts:
15405 tempguy->defense[edefFIRE] = edIGNORE;
15406 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15407 tempguy->defense[edefHOOKSHOT] = 0;
15408 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15409 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15410
15411 if(tempguy->attributes[0]==1)
15412 tempguy->attributes[0]=2;
15413 else if(tempguy->attributes[0]==2)
15414 {
15415 tempguy->attributes[3]=tempguy->attributes[2];
15416 tempguy->attributes[2]=tempguy->attributes[1];
15417 tempguy->attributes[1]=e2tSPLIT;
15418 tempguy->attributes[0] = 0;
15419 }
15420 else tempguy->attributes[0] = 0;
15421
15422 tempguy->flags |= guy_shield_front;
15423
15424 if(!get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15425 tempguy->flags &= ~guy_bkshield;
15426 else
15427 tempguy->flags |= guy_bkshield;
15428
15429 break;
15430 }
15431
15432 tempguy->attributes[9] = 0;
15433 break;
15434
15435 /*
15436 case 9: //eeARMOS
15437 tempguy->family = eeWALK;
15438 break;
15439 */
15440 case 11: //eeGEL
15441 case 33: //eeGELTRIB
15442 if(tempguy->type==33)
15443 {
15444 tempguy->attributes[3] = 1;
15445
15446 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15447 tempguy->attributes[2] = tempguy->attributes[1];
15448
15449 tempguy->attributes[1] = e2tTRIBBLE;
15450 }
15451 else
15452 {
15453 tempguy->attributes[3] = 0;
15454 tempguy->attributes[2] = 0;
15455 tempguy->attributes[1] = 0;
15456 }
15457
15458 tempguy->type = eeWALK;
15459
15460 if(tempguy->attributes[0])
15461 {
15462 tempguy->attributes[0]=1;
15463 tempguy->weapon = ewFireTrail;
15464 }
15465
15466 break;
15467
15468 case 34: //eeZOLTRIB
15469 case 12: //eeZOL
15470 tempguy->attributes[3]=tempguy->attributes[2];
15471 tempguy->attributes[2]=tempguy->attributes[1];
15472 tempguy->type = eeWALK;
15473 tempguy->attributes[1]=e2tSPLITHIT;
15474
15475 if(tempguy->attributes[0])
15476 {
15477 tempguy->attributes[0]=1;
15478 tempguy->weapon = ewFireTrail;
15479 }
15480
15481 break;
15482
15483 case 13: //eeROPE
15484 tempguy->type = eeWALK;
15485 tempguy->attributes[8] = e9tROPE;
15486
15487 if(tempguy->attributes[0])
15488 {
15489 tempguy->attributes[3] = tempguy->attributes[2];
15490 tempguy->attributes[2] = tempguy->attributes[1];
15491 tempguy->attributes[1] = e2tBOMBCHU;
15492 }
15493
15494 tempguy->attributes[0] = 0;
15495 break;
15496
15497 case 14: //eeGORIYA
15498 tempguy->type = eeWALK;
15499
15500 if(tempguy->attributes[0]!=2) tempguy->attributes[0] = 0;
15501
15502 break;
15503
15504 case 17: //eeBUBBLE
15505 tempguy->type = eeWALK;
15506 tempguy->attributes[7] = tempguy->attributes[1];
15507 tempguy->attributes[6] = tempguy->attributes[0] + 1;
15508 tempguy->attributes[0] = tempguy->attributes[1] = 0;
15509
15510 //fallthrogh
15511 case eeTRAP:
15512 case eeROCK:
15513 doesntcount = true;
15514 break;
15515
15516 case 35: //eeVIRETRIB
15517 case 18: //eeVIRE
15518 tempguy->type = eeWALK;
15519 tempguy->attributes[3]=tempguy->attributes[2];
15520 tempguy->attributes[2]=tempguy->attributes[1];
15521 tempguy->attributes[1]=e2tSPLITHIT;
15522 tempguy->attributes[8]=e9tVIRE;
15523 break;
15524
15525 case 19: //eeLIKE
15526 tempguy->type = eeWALK;
15527 tempguy->attributes[6] = e7tEATITEMS;
15528 tempguy->attributes[7]=95;
15529 break;
15530
15531 case 20: //eePOLSV
15532 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15533 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15534 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15535 tempguy->defense[edefARROW] = ed1HKO;
15536 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15537 tempguy->type = eeWALK;
15538 tempguy->attributes[8] = e9tPOLSVOICE;
15539 tempguy->rate = 4;
15540 tempguy->homing = 32;
15541 tempguy->hrate = 10;
15542 tempguy->grumble = 0;
15543 break;
15544
15545 case eeWIZZ:
15546 if(tempguy->attributes[3])
15547 {
15548 for(int32_t i=0; i < edefLAST; i++)
15549 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15550 }
15551 else
15552 {
15553 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15554 tempguy->defense[edefMAGIC] = edCHINK;
15555 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15556 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15557 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15558 }
15559
15560 break;
15561
15562 case eePEAHAT:
15563 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15564
15565 if(!(tempguy->flags & guy_bhit))
15566 tempguy->defense[edefBRANG] = edSTUNONLY;
15567
15568 break;
15569
15570 case eeLEV:
15571 tempguy->defense[edefSTOMP] = edCHINK;
15572 break;
15573 }
15574
15575 // Old flags
15576 if(tempguy->flags & guy_superman)
15577 {
15578 for(int32_t i = 0; i < edefLAST; i++)
15579 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15580 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15581 && tempguy->type != eeROCK && tempguy->type != eeTRAP
15582 && tempguy->type != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15583 }
15584
15585 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15586
15587 if(doesntcount)
15588 tempguy->flags |= (guy_doesnt_count);
15589 }
15590
15591 1178856 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
15592 {
15593 1178856 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
15594
15595 byte tempbyte, padding;
15596 word wpadding;
15597 int32_t extras, secretcombos;
15598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->valid),f))
15599 {
15600 return qe_invalid;
15601 }
15602
15603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->guy),f))
15604 return qe_invalid;
15605 1178856 temp_mapscr->guytile = -1; //signal to use default guy values
15606
2/2
✓ Branch 0 taken 1178256 times.
✓ Branch 1 taken 600 times.
1178856 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15607
4/4
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 1178256 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 538 times.
1178856 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15608
15609
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15610 {
15611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
22176 if(!p_getc(&tempbyte,f))
15612 {
15613 return qe_invalid;
15614 }
15615
15616 22176 temp_mapscr->str=tempbyte;
15617 22176 }
15618 else
15619 {
15620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1156680 times.
1156680 if(!p_igetw(&(temp_mapscr->str),f))
15621 {
15622 return qe_invalid;
15623 }
15624 }
15625
15626
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->room),f))
15627 {
15628 return qe_invalid;
15629 }
15630
15631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->item),f))
15632 {
15633 return qe_invalid;
15634 }
15635
15636
3/6
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 650352 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15637 {
15638 528504 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15639 528504 }
15640 else
15641 {
15642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->hasitem),f))
15643 return qe_invalid;
15644 }
15645
15646
3/4
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1181576 if((Header->zelda_version < 0x192)||
15647
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
1156680 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15648 {
15649
1/2
✓ Branch 0 taken 22176 times.
✗ Branch 1 not taken.
22176 if(!p_getc(&tempbyte,f))
15650 {
15651 return qe_invalid;
15652 }
15653 22176 }
15654
15655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15656 {
15657 return qe_invalid;
15658 }
15659
15660
2/2
✓ Branch 0 taken 1153960 times.
✓ Branch 1 taken 24896 times.
1178856 if(Header->zelda_version < 0x193)
15661 {
15662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24896 times.
24896 if(!p_getc(&tempbyte,f))
15663 {
15664 return qe_invalid;
15665 }
15666 24896 }
15667
15668
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15669 {
15670
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15671 {
15672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15673 {
15674 return qe_invalid;
15675 }
15676 1951056 }
15677 650352 }
15678 else
15679 {
15680 528504 temp_mapscr->tilewarptype[1]=0;
15681 528504 temp_mapscr->tilewarptype[2]=0;
15682 528504 temp_mapscr->tilewarptype[3]=0;
15683 }
15684
15685
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15686 {
15687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1156680 times.
1156680 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15688 {
15689 return qe_invalid;
15690 }
15691 1156680 }
15692
15693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15694 {
15695 return qe_invalid;
15696 }
15697
15698 1178856 temp_mapscr->warpreturnx[1]=0;
15699 1178856 temp_mapscr->warpreturnx[2]=0;
15700 1178856 temp_mapscr->warpreturnx[3]=0;
15701
15702
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15703 {
15704
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15705 {
15706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15707 {
15708 return qe_invalid;
15709 }
15710 1951056 }
15711 650352 }
15712
15713
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15714 {
15715 return qe_invalid;
15716 }
15717
15718 1178856 temp_mapscr->warpreturny[1]=0;
15719 1178856 temp_mapscr->warpreturny[2]=0;
15720 1178856 temp_mapscr->warpreturny[3]=0;
15721
15722
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15723 {
15724
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15725 {
15726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15727 {
15728 return qe_invalid;
15729 }
15730 1951056 }
15731
15732
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(version>=18)
15733 {
15734
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15735 {
15736 return qe_invalid;
15737 }
15738 650352 }
15739 else
15740 {
15741 byte temp;
15742
15743 if(!p_getc(&temp,f))
15744 {
15745 return qe_invalid;
15746 }
15747
15748 temp_mapscr->warpreturnc=temp<<8|temp;
15749 }
15750 650352 }
15751
15752
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->stairx),f))
15753
15754 {
15755 return qe_invalid;
15756 }
15757
15758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->stairy),f))
15759 {
15760 return qe_invalid;
15761 }
15762
15763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->itemx),f))
15764 {
15765 return qe_invalid;
15766 }
15767
15768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->itemy),f))
15769 {
15770 return qe_invalid;
15771 }
15772
15773
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version > 15) // February 2009
15774 {
15775
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&(temp_mapscr->color),f))
15776 {
15777 return qe_invalid;
15778 }
15779 650352 }
15780 else
15781 {
15782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528504 times.
528504 if(!p_getc(& tempbyte,f))
15783 {
15784 return qe_invalid;
15785 }
15786
15787 528504 temp_mapscr->color = (word) tempbyte;
15788 }
15789
15790
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->flags11),f))
15791 {
15792 return qe_invalid;
15793 }
15794
15795
2/2
✓ Branch 0 taken 4715424 times.
✓ Branch 1 taken 1178856 times.
5894280 for(int32_t k=0; k<4; k++)
15796 {
15797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4715424 times.
4715424 if(!p_getc(&(temp_mapscr->door[k]),f))
15798 {
15799 return qe_invalid;
15800
15801 }
15802 4715424 }
15803
15804
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version <= 11)
15805 {
15806
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15807 {
15808 return qe_invalid;
15809 }
15810
15811 528504 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15812
15813
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15814 {
15815 for(int32_t i=1; i<4; i++)
15816 {
15817 if(!p_getc(&(tempbyte),f))
15818 {
15819 return qe_invalid;
15820 }
15821
15822 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15823 }
15824 }
15825 else
15826 {
15827 528504 temp_mapscr->tilewarpdmap[1]=0;
15828 528504 temp_mapscr->tilewarpdmap[2]=0;
15829 528504 temp_mapscr->tilewarpdmap[3]=0;
15830 }
15831 528504 }
15832 else
15833 {
15834
2/2
✓ Branch 0 taken 2601408 times.
✓ Branch 1 taken 650352 times.
3251760 for(int32_t i=0; i<4; i++)
15835 {
15836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2601408 times.
2601408 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15837 {
15838 return qe_invalid;
15839 }
15840 2601408 }
15841 }
15842
15843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15844 {
15845 return qe_invalid;
15846 }
15847
15848
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15849 {
15850
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15851 {
15852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15853 {
15854 return qe_invalid;
15855 }
15856 1951056 }
15857 650352 }
15858 else
15859 {
15860 528504 temp_mapscr->tilewarpscr[1]=0;
15861 528504 temp_mapscr->tilewarpscr[2]=0;
15862 528504 temp_mapscr->tilewarpscr[3]=0;
15863 }
15864
15865
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version >= 15)
15866 {
15867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15868 {
15869 return qe_invalid;
15870 }
15871 650352 }
15872 else
15873 {
15874 528504 temp_mapscr->tilewarpoverlayflags=0;
15875 }
15876
15877
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->exitdir),f))
15878 {
15879 return qe_invalid;
15880 }
15881
15882
2/2
✓ Branch 0 taken 1153960 times.
✓ Branch 1 taken 24896 times.
1178856 if(Header->zelda_version < 0x193)
15883 {
15884
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if(!p_getc(&tempbyte,f))
15885 {
15886 return qe_invalid;
15887 }
15888
15889 24896 }
15890
15891
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15892 {
15893 if(!p_getc(&padding,f))
15894 {
15895 return qe_invalid;
15896 }
15897 }
15898
15899
2/2
✓ Branch 0 taken 11788560 times.
✓ Branch 1 taken 1178856 times.
12967416 for(int32_t k=0; k<10; k++)
15900 {
15901
5/6
✓ Branch 0 taken 11566800 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11539600 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11788560 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15902 {
15903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if(!p_getc(&tempbyte,f))
15904 {
15905 return qe_invalid;
15906 }
15907
15908 221760 temp_mapscr->enemy[k]=tempbyte;
15909
15910 // 76 is the highest enemy id possible to set in 1.90. Anything higher must have come
15911 // from corrupting when 1.90 saved the quest.
15912 // https://discord.com/channels/876899628556091432/1287580827164737658
15913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if (Header->zelda_version <= 0x190)
15914 {
15915
1/2
✓ Branch 0 taken 221760 times.
✗ Branch 1 not taken.
221760 if (temp_mapscr->enemy[k] > 76)
15916 {
15917 temp_mapscr->enemy[k] = 0;
15918 }
15919 221760 }
15920 221760 }
15921 else
15922 {
15923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11566800 times.
11566800 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15924 {
15925 return qe_invalid;
15926 }
15927 }
15928
15929
5/6
✓ Branch 0 taken 11566800 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11539600 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11788560 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15930 {
15931 //using enumerations here is dangerous
15932 //very easy to break old quests -DD
15933
2/2
✓ Branch 0 taken 1342 times.
✓ Branch 1 taken 220418 times.
221760 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15934 {
15935 1342 temp_mapscr->enemy[k]+=5;
15936 1342 }
15937
2/2
✓ Branch 0 taken 220324 times.
✓ Branch 1 taken 94 times.
220418 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15938 {
15939 94 temp_mapscr->enemy[k]+=1;
15940 94 }
15941 221760 }
15942
15943
2/2
✓ Branch 0 taken 6503520 times.
✓ Branch 1 taken 5285040 times.
11788560 if(version < 9)
15944 {
15945
2/2
✓ Branch 0 taken 5009135 times.
✓ Branch 1 taken 275905 times.
5285040 if(temp_mapscr->enemy[k]>0)
15946 {
15947 275905 temp_mapscr->enemy[k]+=10;
15948 275905 }
15949 5285040 }
15950 //don't read in any invalid data
15951
2/2
✓ Branch 0 taken 11788110 times.
✓ Branch 1 taken 450 times.
11788560 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15952 {
15953 450 al_trace("Tried to read an invalid enemy ID (%d) for enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15954 450 temp_mapscr->enemy[k] = 0;
15955 450 }
15956 11788560 }
15957
15958
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->pattern),f))
15959 {
15960 return qe_invalid;
15961 }
15962
15963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15964 {
15965 return qe_invalid;
15966 }
15967
15968
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15969 {
15970
2/2
✓ Branch 0 taken 1951056 times.
✓ Branch 1 taken 650352 times.
2601408 for(int32_t i=1; i<4; i++)
15971 {
15972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15973 {
15974 return qe_invalid;
15975 }
15976 1951056 }
15977 650352 }
15978 else
15979 {
15980 528504 temp_mapscr->sidewarptype[1]=0;
15981 528504 temp_mapscr->sidewarptype[2]=0;
15982 528504 temp_mapscr->sidewarptype[3]=0;
15983 }
15984
15985
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version >= 15)
15986 {
15987
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15988 {
15989 return qe_invalid;
15990 }
15991 650352 }
15992 else
15993 {
15994 528504 temp_mapscr->sidewarpoverlayflags=0;
15995 }
15996
15997
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15998 {
15999 return qe_invalid;
16000 }
16001
16002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->warparrivaly),f))
16003 {
16004 return qe_invalid;
16005 }
16006
16007
2/2
✓ Branch 0 taken 4715424 times.
✓ Branch 1 taken 1178856 times.
5894280 for(int32_t k=0; k<4; k++)
16008 {
16009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4715424 times.
4715424 if(!p_getc(&(temp_mapscr->path[k]),f))
16010 {
16011 return qe_invalid;
16012 }
16013 4715424 }
16014
16015
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
16016 {
16017 return qe_invalid;
16018 }
16019
16020
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16021 {
16022
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 1951056 times.
2601408 for(int32_t i=1; i<4; i++)
16023 {
16024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1951056 times.
1951056 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16025 {
16026 return qe_invalid;
16027 }
16028 1951056 }
16029 650352 }
16030 else
16031 {
16032 528504 temp_mapscr->sidewarpscr[1]=0;
16033 528504 temp_mapscr->sidewarpscr[2]=0;
16034 528504 temp_mapscr->sidewarpscr[3]=0;
16035 }
16036
16037
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version <= 11)
16038 {
16039
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
16040 {
16041 return qe_invalid;
16042 }
16043
16044 528504 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
16045
16046
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16047 {
16048 for(int32_t i=1; i<4; i++)
16049 {
16050 if(!p_getc(&(tempbyte),f))
16051 {
16052 return qe_invalid;
16053 }
16054
16055 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
16056 }
16057 }
16058 else
16059 {
16060 528504 temp_mapscr->sidewarpdmap[1]=0;
16061 528504 temp_mapscr->sidewarpdmap[2]=0;
16062 528504 temp_mapscr->sidewarpdmap[3]=0;
16063 }
16064 528504 }
16065 else
16066 {
16067
2/2
✓ Branch 0 taken 2601408 times.
✓ Branch 1 taken 650352 times.
3251760 for(int32_t i=0; i<4; i++)
16068 {
16069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2601408 times.
2601408 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16070 {
16071 return qe_invalid;
16072 }
16073 2601408 }
16074 }
16075
16076
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16077 {
16078
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16079 {
16080 return qe_invalid;
16081 }
16082 650352 }
16083 528504 else temp_mapscr->sidewarpindex = 0;
16084
16085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_igetw(&(temp_mapscr->undercombo),f))
16086 {
16087 return qe_invalid;
16088 }
16089
16090 1178856 byte old_combo_page = 0;
16091
2/2
✓ Branch 0 taken 1153960 times.
✓ Branch 1 taken 24896 times.
1178856 if(Header->zelda_version < 0x193)
16092 {
16093
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if (!p_getc(&old_combo_page, f))
16094 {
16095 return qe_invalid;
16096 }
16097
16098
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 24624 times.
24896 if (!should_skip)
16099 {
16100 24624 old_combo_pages[scrind] = old_combo_page;
16101 24624 }
16102 24896 }
16103
16104
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
16105 {
16106 return qe_invalid;
16107 }
16108
16109
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_igetw(&(temp_mapscr->catchall),f))
16110 {
16111 return qe_invalid;
16112 }
16113
16114
1/2
✓ Branch 0 taken 1178856 times.
✗ Branch 1 not taken.
1178856 if(!p_getc(&(temp_mapscr->flags),f))
16115 {
16116 return qe_invalid;
16117 }
16118
16119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->flags2),f))
16120 {
16121 return qe_invalid;
16122 }
16123
16124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(!p_getc(&(temp_mapscr->flags3),f))
16125 {
16126 return qe_invalid;
16127 }
16128
16129
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16130 //if (version>2)
16131 {
16132
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags4),f))
16133 {
16134 return qe_invalid;
16135 }
16136 650352 }
16137
16138
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16139 {
16140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->flags5),f))
16141 {
16142 return qe_invalid;
16143 }
16144
16145
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&wpadding,f))
16146 return qe_invalid;
16147 650352 temp_mapscr->noreset = wpadding | mLIGHTBEAM | mTMPNORET | mVISITED;
16148
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&wpadding,f))
16149 return qe_invalid;
16150 1300704 temp_mapscr->nocarry = wpadding | mLIGHTBEAM | mTMPNORET | mVISITED |
16151 650352 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
16152
16153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(temp_mapscr->flags5&32)
16154 {
16155 temp_mapscr->flags5 &= ~32;
16156 temp_mapscr->noreset |= 48;
16157 }
16158
16159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(version<8)
16160 {
16161 if(temp_mapscr->noreset&1)
16162 {
16163 temp_mapscr->noreset|=8192;
16164 }
16165
16166 if(temp_mapscr->nocarry&1)
16167 {
16168 temp_mapscr->nocarry|=8192;
16169 temp_mapscr->nocarry&=~1;
16170 }
16171 }
16172 650352 }
16173 else
16174 {
16175 528504 temp_mapscr->flags5 = 0;
16176 528504 temp_mapscr->noreset = mLIGHTBEAM | mTMPNORET | mVISITED;
16177 528504 temp_mapscr->nocarry = mLIGHTBEAM | mTMPNORET | mVISITED |
16178 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
16179 }
16180
16181
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16182 {
16183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->flags6),f))
16184 {
16185 return qe_invalid;
16186 }
16187 650352 }
16188
16189
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version>5)
16190 {
16191
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags7),f))
16192 {
16193 return qe_invalid;
16194 }
16195
16196
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags8),f))
16197 {
16198 return qe_invalid;
16199 }
16200
16201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->flags9),f))
16202 {
16203 return qe_invalid;
16204 }
16205
16206
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->flags10),f))
16207 {
16208 return qe_invalid;
16209 }
16210
16211
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->csensitive),f))
16212 {
16213 return qe_invalid;
16214 }
16215 650352 }
16216 else
16217 {
16218 528504 temp_mapscr->csensitive=1;
16219 }
16220
16221
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version<14) // August 2007: screen SFX added
16222 {
16223
2/2
✓ Branch 0 taken 527510 times.
✓ Branch 1 taken 994 times.
528504 if(temp_mapscr->flags&8) //fROAR
16224 {
16225 994 temp_mapscr->bosssfx=
16226
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 853 times.
994 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16227 853 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16228 WAV_ROAR;
16229 994 }
16230
16231
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 528334 times.
528504 if(temp_mapscr->flags&128) //fSEA_SFX
16232 {
16233 170 temp_mapscr->oceansfx=WAV_SEA;
16234 170 }
16235
16236 528504 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16237 ? 0 : WAV_SECRET;
16238
16239 528504 temp_mapscr->flags3 &= ~66; //64|2
16240 528504 temp_mapscr->flags2 &= ~32;
16241 528504 temp_mapscr->flags &= ~136; // 128|8
16242 528504 }
16243 else
16244 {
16245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->oceansfx),f))
16246 {
16247 return qe_invalid;
16248 }
16249
16250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->bosssfx),f))
16251 {
16252 return qe_invalid;
16253 }
16254
16255
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->secretsfx),f))
16256 {
16257 return qe_invalid;
16258 }
16259 }
16260
16261
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version<15) // October 2007: another SFX
16262 {
16263 528504 temp_mapscr->holdupsfx=WAV_PICKUP;
16264 528504 }
16265 else
16266 {
16267
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->holdupsfx),f))
16268 {
16269 return qe_invalid;
16270 }
16271 }
16272
16273
16274
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16275 {
16276
2/2
✓ Branch 0 taken 6940080 times.
✓ Branch 1 taken 1156680 times.
8096760 for(int32_t k=0; k<6; k++)
16277 {
16278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6940080 times.
6940080 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16279 {
16280 return qe_invalid;
16281 }
16282 6940080 }
16283
16284
2/2
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 6940080 times.
8096760 for(int32_t k=0; k<6; k++)
16285 {
16286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6940080 times.
6940080 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16287 {
16288 return qe_invalid;
16289 }
16290 6940080 }
16291 1156680 }
16292
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22176 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16293 {
16294 if(!p_getc(&(temp_mapscr->layermap[2]),f))
16295 {
16296 return qe_invalid;
16297 }
16298
16299 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
16300 {
16301 return qe_invalid;
16302 }
16303
16304 if(!p_getc(&(temp_mapscr->layermap[4]),f))
16305 {
16306 return qe_invalid;
16307 }
16308
16309 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
16310
16311 {
16312 return qe_invalid;
16313 }
16314 }
16315
16316
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>149))
16317 {
16318
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16319 {
16320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxsize
16321 {
16322 return qe_invalid;
16323 }
16324 16320 }
16325
16326
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16327 {
16328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxspeed
16329 {
16330 return qe_invalid;
16331 }
16332 16320 }
16333
16334
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16335 {
16336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxdelay
16337 {
16338 return qe_invalid;
16339 }
16340 16320 }
16341
16342
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16343 {
16344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerysize
16345 {
16346 return qe_invalid;
16347 }
16348 16320 }
16349
16350
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
16351 {
16352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layeryspeed
16353 {
16354 return qe_invalid;
16355 }
16356 16320 }
16357
16358
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 16320 times.
19040 for(int32_t k=0; k<6; k++)
16359 {
16360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerydelay
16361 {
16362 return qe_invalid;
16363 }
16364 16320 }
16365 2720 }
16366
16367
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16368 {
16369
2/2
✓ Branch 0 taken 6940080 times.
✓ Branch 1 taken 1156680 times.
8096760 for(int32_t k=0; k<6; k++)
16370 {
16371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6940080 times.
6940080 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16372 {
16373 return qe_invalid;
16374 }
16375 6940080 }
16376 1156680 }
16377
16378
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16379 {
16380
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 if((Header->zelda_version == 0x192)&&(Header->build>153))
16381 {
16382
1/2
✓ Branch 0 taken 2720 times.
✗ Branch 1 not taken.
2720 if(!p_getc(&padding,f))
16383 {
16384 return qe_invalid;
16385 }
16386 2720 }
16387
16388
1/2
✓ Branch 0 taken 1156680 times.
✗ Branch 1 not taken.
1156680 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16389 {
16390 return qe_invalid;
16391 }
16392 1156680 }
16393
16394
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16395 {
16396 22176 extras=15;
16397 22176 }
16398
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16399 {
16400 extras=11;
16401 }
16402
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
1156680 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16403 {
16404 extras=32;
16405 }
16406
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16407 {
16408 extras=64;
16409 }
16410
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
1156680 else if(Header->zelda_version < 0x193)
16411 {
16412 2720 extras=62;
16413 2720 }
16414 else
16415
16416 {
16417 1153960 extras=0;
16418 }
16419
16420
2/2
✓ Branch 0 taken 501280 times.
✓ Branch 1 taken 1178856 times.
1680136 for(int32_t k=0; k<extras; k++)
16421 {
16422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 501280 times.
501280 if(!p_getc(&tempbyte,f)) //extra[k]
16423 {
16424 return qe_invalid;
16425 }
16426 501280 }
16427
16428
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16429 //if (version>3)
16430 {
16431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_getc(&(temp_mapscr->nextmap),f))
16432 {
16433 return qe_invalid;
16434 }
16435
16436
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->nextscr),f))
16437 {
16438 return qe_invalid;
16439 }
16440 650352 }
16441 else
16442 {
16443 528504 temp_mapscr->nextmap=0;
16444 528504 temp_mapscr->nextscr=0;
16445 }
16446
16447
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16448 {
16449 22176 secretcombos=20;
16450 22176 }
16451
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1153960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1156680 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16452 {
16453 secretcombos=256;
16454 }
16455 else
16456 {
16457 1156680 secretcombos=128;
16458 }
16459
16460
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16461 {
16462
2/2
✓ Branch 0 taken 443520 times.
✓ Branch 1 taken 22176 times.
465696 for(int32_t k=0; k<secretcombos; k++)
16463 {
16464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(!p_getc(&tempbyte,f))
16465 {
16466 return qe_invalid;
16467 }
16468
16469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(k<128)
16470 {
16471 443520 temp_mapscr->secretcombo[k]=tempbyte;
16472 443520 }
16473 443520 }
16474 22176 }
16475 else
16476 {
16477
2/2
✓ Branch 0 taken 148055040 times.
✓ Branch 1 taken 1156680 times.
149211720 for(int32_t k=0; k<128; k++)
16478 {
16479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148055040 times.
148055040 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16480 {
16481 return qe_invalid;
16482 }
16483
16484 148055040 }
16485 }
16486
16487
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16488 {
16489
2/2
✓ Branch 0 taken 148055040 times.
✓ Branch 1 taken 1156680 times.
149211720 for(int32_t k=0; k<128; k++)
16490 {
16491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148055040 times.
148055040 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16492 {
16493 return qe_invalid;
16494 }
16495 148055040 }
16496
16497
2/2
✓ Branch 0 taken 148055040 times.
✓ Branch 1 taken 1156680 times.
149211720 for(int32_t k=0; k<128; k++)
16498 {
16499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 148055040 times.
148055040 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16500 {
16501 return qe_invalid;
16502 }
16503 148055040 }
16504 1156680 }
16505
16506
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16507 {
16508 if(!p_getc(&padding,f))
16509 {
16510 return qe_invalid;
16511 }
16512 }
16513
16514
2/2
✓ Branch 0 taken 207478656 times.
✓ Branch 1 taken 1178856 times.
208657512 for(int32_t k=0; k<176; k++)
16515 {
16516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 207478656 times.
207478656 if(!p_igetw(&(temp_mapscr->data[k]),f))
16517 {
16518 return qe_invalid;
16519 }
16520 207478656 }
16521
16522
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1176136 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16523 {
16524 if(!p_getc(&padding,f))
16525 {
16526 return qe_invalid;
16527 }
16528
16529 if(!p_getc(&padding,f))
16530 {
16531 return qe_invalid;
16532 }
16533 }
16534
16535
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16536 {
16537
2/2
✓ Branch 0 taken 203575680 times.
✓ Branch 1 taken 1156680 times.
204732360 for(int32_t k=0; k<176; k++)
16538 {
16539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203575680 times.
203575680 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16540 {
16541 return qe_invalid;
16542 }
16543
16544
3/4
✓ Branch 0 taken 478720 times.
✓ Branch 1 taken 203096960 times.
✓ Branch 2 taken 478720 times.
✗ Branch 3 not taken.
203575680 if((Header->zelda_version == 0x192)&&(Header->build<24))
16545 {
16546 if(!p_getc(&tempbyte,f))
16547 {
16548 return qe_invalid;
16549 }
16550
16551 if(!p_getc(&tempbyte,f))
16552 {
16553 return qe_invalid;
16554 }
16555
16556 if(!p_getc(&tempbyte,f))
16557 {
16558 return qe_invalid;
16559 }
16560 }
16561 203575680 }
16562 1156680 }
16563
16564
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1153960 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1178856 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16565 {
16566
2/2
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 203575680 times.
204732360 for(int32_t k=0; k<176; k++)
16567 {
16568
16569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203575680 times.
203575680 if(!p_getc(&(temp_mapscr->cset[k]),f))
16570 {
16571 return qe_invalid;
16572 }
16573 203575680 }
16574 1156680 }
16575
16576
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16577 {
16578 22176 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16579 22176 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(old_combo_page<<8);
16580 22176 }
16581
16582
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16583 {
16584 22176 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16585 22176 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16586 22176 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16587 22176 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16588 22176 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16589 22176 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16590 22176 }
16591
16592
5/6
✓ Branch 0 taken 1156680 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1153960 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1178856 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16593 {
16594
2/2
✓ Branch 0 taken 3902976 times.
✓ Branch 1 taken 22176 times.
3925152 for(int32_t k=0; k<176; k++)
16595 {
16596
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version == 0x192)&&(Header->build>149))
16597 {
16598 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16599 {
16600 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16601 }
16602 }
16603 else
16604 {
16605
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version < 0x192)||
16606 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16607 {
16608 3902976 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16609 3902976 }
16610
16611 3902976 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16612 }
16613
16614 3902976 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(old_combo_page<<8);
16615 3902976 }
16616 22176 }
16617
16618 /*if(version>12)
16619 {
16620 if(!p_getc(&(temp_mapscr->scrWidth),f))
16621 {
16622 return qe_invalid;
16623 }
16624 if(!p_getc(&(temp_mapscr->scrHeight),f))
16625 {
16626 return qe_invalid;
16627 }
16628 }*/
16629
16630
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version>4)
16631 {
16632
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16633 {
16634 return qe_invalid;
16635 }
16636 650352 }
16637 else
16638 {
16639 528504 temp_mapscr->screen_midi = -1;
16640 }
16641
16642
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version>=17)
16643 {
16644
1/2
✓ Branch 0 taken 650352 times.
✗ Branch 1 not taken.
650352 if(!p_getc(&(temp_mapscr->lens_layer),f))
16645 {
16646 return qe_invalid;
16647 }
16648 650352 }
16649 else
16650 {
16651 528504 temp_mapscr->lens_layer = llNORMAL;
16652 }
16653
16654
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 650352 times.
1178856 if(version>6)
16655 {
16656 dword bits;
16657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 650352 times.
650352 if(!p_igetl(&bits,f))
16658 {
16659 return qe_invalid;
16660 }
16661
16662 int32_t m;
16663 float tempfloat;
16664 word tempw;
16665 650352 temp_mapscr->ffcCountMarkDirty();
16666 650352 temp_mapscr->ffcs.clear();
16667 650352 temp_mapscr->resizeFFC(std::bit_width(bits));
16668
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 20811264 times.
21461616 for(m=0; m<32; m++)
16669 {
16670
2/2
✓ Branch 0 taken 20536512 times.
✓ Branch 1 taken 274752 times.
20811264 if((bits>>m)&1)
16671 {
16672 274752 ffcdata& tempffc = temp_mapscr->ffcs[m];
16673
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(!p_igetw(&tempw,f))
16674 {
16675 return qe_invalid;
16676 }
16677 274752 tempffc.data = tempw;
16678
16679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempffc.cset),f))
16680 {
16681 return qe_invalid;
16682 }
16683
16684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetw(&(tempffc.delay),f))
16685 {
16686 return qe_invalid;
16687 }
16688
16689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(version < 9)
16690 {
16691 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16692 {
16693 return qe_invalid;
16694 }
16695
16696 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16697
16698 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16699 {
16700 return qe_invalid;
16701 }
16702
16703 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16704
16705 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16706 {
16707 return qe_invalid;
16708 }
16709
16710 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16711
16712 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16713 {
16714 return qe_invalid;
16715 }
16716
16717 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16718
16719 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16720 {
16721 return qe_invalid;
16722 }
16723
16724 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16725
16726 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16727 {
16728 return qe_invalid;
16729 }
16730
16731 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16732 }
16733 else
16734 {
16735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.x),f))
16736 {
16737 return qe_invalid;
16738 }
16739
16740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.y),f))
16741 {
16742 return qe_invalid;
16743 }
16744
16745
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(!p_igetzf(&(tempffc.vx),f))
16746 {
16747 return qe_invalid;
16748 }
16749
16750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.vy),f))
16751 {
16752 return qe_invalid;
16753 }
16754
16755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.ax),f))
16756 {
16757 return qe_invalid;
16758 }
16759
16760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetzf(&(tempffc.ay),f))
16761 {
16762 return qe_invalid;
16763 }
16764 }
16765
16766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempffc.link),f))
16767 {
16768 return qe_invalid;
16769 }
16770
16771
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(version>7)
16772 {
16773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&tempbyte,f))
16774 {
16775 return qe_invalid;
16776 }
16777
16778 274752 tempffc.hit_width = (tempbyte&0x3F)+1;
16779 274752 tempffc.txsz = (tempbyte>>6)+1;
16780
16781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&tempbyte,f))
16782 {
16783 return qe_invalid;
16784 }
16785
16786 274752 tempffc.hit_height = (tempbyte&0x3F)+1;
16787 274752 tempffc.tysz = (tempbyte>>6)+1;
16788
16789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.flags),f))
16790 {
16791 return qe_invalid;
16792 }
16793 274752 }
16794 else
16795 {
16796 tempffc.hit_width=16;
16797 tempffc.hit_height=16;
16798 tempffc.txsz=1;
16799 tempffc.tysz=1;
16800 tempffc.flags=ffc_none;
16801 }
16802
16803 274752 tempffc.updateSolid();
16804
16805
16806
4/6
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268748 times.
✓ Branch 3 taken 6004 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 268748 times.
274752 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16807 {
16808 tempffc.flags|=ffc_ignoreholdup;
16809 }
16810
16811
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(version>9)
16812 {
16813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetw(&(tempffc.script),f))
16814 {
16815 return qe_invalid;
16816 }
16817 274752 }
16818 else
16819 {
16820 tempffc.script=0;
16821 }
16822
16823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(version>10)
16824 {
16825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[0]),f))
16826 {
16827 return qe_invalid;
16828 }
16829
16830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[1]),f))
16831 {
16832 return qe_invalid;
16833 }
16834
16835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[2]),f))
16836 {
16837 return qe_invalid;
16838 }
16839
16840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[3]),f))
16841 {
16842 return qe_invalid;
16843 }
16844
16845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[4]),f))
16846 {
16847 return qe_invalid;
16848 }
16849
16850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[5]),f))
16851 {
16852 return qe_invalid;
16853 }
16854
16855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[6]),f))
16856 {
16857 return qe_invalid;
16858 }
16859
16860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_igetl(&(tempffc.initd[7]),f))
16861 {
16862 return qe_invalid;
16863 }
16864
16865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempbyte),f))
16866 {
16867 return qe_invalid;
16868 }
16869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274752 times.
274752 if(!p_getc(&(tempbyte),f))
16870 {
16871 return qe_invalid;
16872 }
16873 274752 }
16874
16875
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
16876 {
16877 tempffc.script = 0;
16878 for(int q = 0; q < 8; ++q)
16879 tempffc.initd[q] = 0;
16880 }
16881
1/2
✓ Branch 0 taken 274752 times.
✗ Branch 1 not taken.
274752 if(version <= 11)
16882 {
16883 fixffcs=true;
16884 }
16885 274752 }
16886 20811264 }
16887
16888 650352 temp_mapscr->shrinkToFitFFCs();
16889 650352 }
16890
16891
16892 //add in the new whistle flags
16893
2/2
✓ Branch 0 taken 650352 times.
✓ Branch 1 taken 528504 times.
1178856 if(version<13)
16894 {
16895
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 528380 times.
528504 if(temp_mapscr->flags & fWHISTLE)
16896 {
16897 124 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16898 124 }
16899 528504 }
16900
16901 //2.55 starts here
16902
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 19 && Header->zelda_version > 0x253 )
16903 {
16904 // mapscr fields that were never used, so are now removed:
16905 // int32_t npcstrings[10];
16906 // int16_t new_items[10];
16907 // int16_t new_item_x[10];
16908 // int16_t new_item_y[10];
16909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if (pack_fseek(f, 100))
16910 {
16911 return qe_invalid;
16912 }
16913 34408 }
16914
16915
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 20 && Header->zelda_version > 0x253 )
16916 {
16917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_igetw(&(temp_mapscr->script),f))
16918 {
16919 return qe_invalid;
16920 }
16921
2/2
✓ Branch 0 taken 275264 times.
✓ Branch 1 taken 34408 times.
309672 for ( int32_t q = 0; q < 8; q++)
16922 {
16923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275264 times.
275264 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16924 {
16925 return qe_invalid;
16926 }
16927 275264 }
16928 34408 }
16929
2/2
✓ Branch 0 taken 1144448 times.
✓ Branch 1 taken 34408 times.
1178856 if ( version < 20 )
16930 {
16931 1144448 temp_mapscr->script = 0;
16932
2/2
✓ Branch 0 taken 9155584 times.
✓ Branch 1 taken 1144448 times.
10300032 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16933 1144448 }
16934
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 21 && Header->zelda_version > 0x253 )
16935 {
16936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_getc(&(temp_mapscr->preloadscript),f))
16937 {
16938 return qe_invalid;
16939 }
16940 34408 }
16941
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
1178856 if ( version < 21 )
16942 {
16943 1144448 temp_mapscr->preloadscript = 0;
16944 1144448 }
16945
16946
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1178856 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16947 {
16948
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16949 {
16950 return qe_invalid;
16951 }
16952
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16953 {
16954 return qe_invalid;
16955 }
16956 34408 }
16957
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1144448 times.
1178856 if ( version < 22 )
16958 {
16959 1144448 temp_mapscr->hidelayers = 0;
16960 1144448 temp_mapscr->hidescriptlayers = 0;
16961 1144448 }
16962
16963 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16964 //May be any version before 2.11. -Z
16965 /* --not the roar, the HIT SFX
16966 if ( Header->zelda_version <= 0x210 )
16967 {
16968 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16969 {
16970 temp_mapscr->bosssfx = WAV_ROAR;
16971 }
16972 }
16973 */
16974
2/2
✓ Branch 0 taken 4715424 times.
✓ Branch 1 taken 1178856 times.
5894280 for(int32_t k=0; k<4; k++)
16975 {
16976
1/2
✓ Branch 0 taken 4715424 times.
✗ Branch 1 not taken.
4715424 if(temp_mapscr->door[k] == dNONE)
16977 temp_mapscr->door[k] = dWALL;
16978 4715424 }
16979
16980 1178856 return 0;
16981 1178856 }
16982 1558296 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
16983 {
16984
2/2
✓ Branch 0 taken 1178856 times.
✓ Branch 1 taken 379440 times.
1558296 if(version < 23)
16985 {
16986 1178856 auto ret = readmapscreen_old(f,Header,temp_mapscr,version,scrind);
16987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1178856 times.
1178856 if(ret) return ret;
16988 1178856 }
16989 else
16990 {
16991
1/2
✓ Branch 0 taken 379440 times.
✗ Branch 1 not taken.
379440 if(!p_getc(&(temp_mapscr->valid),f))
16992 return qe_invalid;
16993
2/2
✓ Branch 0 taken 192704 times.
✓ Branch 1 taken 186736 times.
379440 if(!(temp_mapscr->valid & mVALID))
16994 {
16995 186736 int map = scrind/MAPSCRS;
16996 186736 int screen = scrind%MAPSCRS;
16997
4/6
✓ Branch 0 taken 179634 times.
✓ Branch 1 taken 7102 times.
✓ Branch 2 taken 179634 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 179634 times.
186736 if(version > 25 && scrind > -1 && map < map_infos.size())
16998 {
16999 179634 auto const& mapinf = map_infos[map];
17000 //Empty screen, apply defaults
17001
2/2
✓ Branch 0 taken 1077804 times.
✓ Branch 1 taken 179634 times.
1257438 for(int q = 0; q < 6; ++q)
17002 {
17003 1077804 auto layermap = mapinf.autolayers[q];
17004 1077804 temp_mapscr->layermap[q] = layermap;
17005
2/2
✓ Branch 0 taken 1007027 times.
✓ Branch 1 taken 70777 times.
1077804 if(layermap)
17006 70777 temp_mapscr->layerscreen[q] = screen;
17007 1077804 }
17008 179634 temp_mapscr->color = mapinf.autopalette;
17009 179634 }
17010 186736 return 0;
17011 }
17012 uint32_t scr_has_flags;
17013
1/2
✓ Branch 0 taken 192704 times.
✗ Branch 1 not taken.
192704 if(!p_igetl(&scr_has_flags,f))
17014 return qe_invalid;
17015
17016
2/2
✓ Branch 0 taken 10458 times.
✓ Branch 1 taken 182246 times.
192704 if(scr_has_flags & SCRHAS_ROOMDATA)
17017 {
17018
1/2
✓ Branch 0 taken 182246 times.
✗ Branch 1 not taken.
182246 if(!p_getc(&(temp_mapscr->guy),f))
17019 return qe_invalid;
17020
2/2
✓ Branch 0 taken 182126 times.
✓ Branch 1 taken 120 times.
182246 if(version > 26)
17021 {
17022
1/2
✓ Branch 0 taken 182126 times.
✗ Branch 1 not taken.
182126 if(!p_igetl(&(temp_mapscr->guytile),f))
17023 return qe_invalid;
17024
1/2
✓ Branch 0 taken 182126 times.
✗ Branch 1 not taken.
182126 if(!p_getc(&(temp_mapscr->guycs),f))
17025 return qe_invalid;
17026
1/2
✓ Branch 0 taken 182126 times.
✗ Branch 1 not taken.
182126 if(!p_igetw(&(temp_mapscr->roomflags),f))
17027 return qe_invalid;
17028 182126 }
17029 else
17030 {
17031 120 temp_mapscr->guytile = -1; //signal to use default guy values
17032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
17033
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
120 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
17034 }
17035
1/2
✓ Branch 0 taken 182246 times.
✗ Branch 1 not taken.
182246 if(!p_igetw(&(temp_mapscr->str),f))
17036 return qe_invalid;
17037
1/2
✓ Branch 0 taken 182246 times.
✗ Branch 1 not taken.
182246 if(!p_getc(&(temp_mapscr->room),f))
17038 return qe_invalid;
17039
1/2
✓ Branch 0 taken 182246 times.
✗ Branch 1 not taken.
182246 if(!p_igetw(&(temp_mapscr->catchall),f))
17040 return qe_invalid;
17041 182246 }
17042
2/2
✓ Branch 0 taken 187882 times.
✓ Branch 1 taken 4822 times.
192704 if(scr_has_flags & SCRHAS_ITEM)
17043 {
17044
1/2
✓ Branch 0 taken 4822 times.
✗ Branch 1 not taken.
4822 if(!p_getc(&(temp_mapscr->item),f))
17045 return qe_invalid;
17046
1/2
✓ Branch 0 taken 4822 times.
✗ Branch 1 not taken.
4822 if(!p_getc(&(temp_mapscr->hasitem),f))
17047 return qe_invalid;
17048
1/2
✓ Branch 0 taken 4822 times.
✗ Branch 1 not taken.
4822 if(!p_getc(&(temp_mapscr->itemx),f))
17049 return qe_invalid;
17050
1/2
✓ Branch 0 taken 4822 times.
✗ Branch 1 not taken.
4822 if(!p_getc(&(temp_mapscr->itemy),f))
17051 return qe_invalid;
17052 4822 }
17053
2/2
✓ Branch 0 taken 175125 times.
✓ Branch 1 taken 17579 times.
192704 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
17054 {
17055
1/2
✓ Branch 0 taken 17579 times.
✗ Branch 1 not taken.
17579 if(!p_igetw(&temp_mapscr->warpreturnc,f))
17056 return qe_invalid;
17057 17579 }
17058
2/2
✓ Branch 0 taken 185648 times.
✓ Branch 1 taken 7056 times.
192704 if(scr_has_flags & SCRHAS_TWARP)
17059 {
17060
2/2
✓ Branch 0 taken 28224 times.
✓ Branch 1 taken 7056 times.
35280 for(int32_t i=0; i<4; i++)
17061 {
17062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28224 times.
28224 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
17063 return qe_invalid;
17064 28224 }
17065
2/2
✓ Branch 0 taken 28224 times.
✓ Branch 1 taken 7056 times.
35280 for(int32_t i=0; i<4; i++)
17066 {
17067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28224 times.
28224 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
17068 return qe_invalid;
17069 28224 }
17070
2/2
✓ Branch 0 taken 28224 times.
✓ Branch 1 taken 7056 times.
35280 for(int32_t i=0; i<4; i++)
17071 {
17072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28224 times.
28224 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
17073 return qe_invalid;
17074 28224 }
17075
1/2
✓ Branch 0 taken 7056 times.
✗ Branch 1 not taken.
7056 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
17076 return qe_invalid;
17077 7056 }
17078
2/2
✓ Branch 0 taken 180776 times.
✓ Branch 1 taken 11928 times.
192704 if(scr_has_flags & SCRHAS_SWARP)
17079 {
17080
2/2
✓ Branch 0 taken 47712 times.
✓ Branch 1 taken 11928 times.
59640 for(int32_t i=0; i<4; i++)
17081 {
17082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47712 times.
47712 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
17083 return qe_invalid;
17084 47712 }
17085
2/2
✓ Branch 0 taken 47712 times.
✓ Branch 1 taken 11928 times.
59640 for(int32_t i=0; i<4; i++)
17086 {
17087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47712 times.
47712 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
17088 return qe_invalid;
17089 47712 }
17090
2/2
✓ Branch 0 taken 47712 times.
✓ Branch 1 taken 11928 times.
59640 for(int32_t i=0; i<4; i++)
17091 {
17092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47712 times.
47712 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
17093 return qe_invalid;
17094 47712 }
17095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11928 times.
11928 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
17096 return qe_invalid;
17097
1/2
✓ Branch 0 taken 11928 times.
✗ Branch 1 not taken.
11928 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
17098 return qe_invalid;
17099 11928 }
17100
2/2
✓ Branch 0 taken 180033 times.
✓ Branch 1 taken 12671 times.
192704 if(scr_has_flags & SCRHAS_WARPRET)
17101 {
17102
2/2
✓ Branch 0 taken 50684 times.
✓ Branch 1 taken 12671 times.
63355 for(int32_t i=0; i<4; i++)
17103 {
17104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50684 times.
50684 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
17105 return qe_invalid;
17106 50684 }
17107
2/2
✓ Branch 0 taken 50684 times.
✓ Branch 1 taken 12671 times.
63355 for(int32_t i=0; i<4; i++)
17108 {
17109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50684 times.
50684 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
17110 return qe_invalid;
17111 50684 }
17112
1/2
✓ Branch 0 taken 12671 times.
✗ Branch 1 not taken.
12671 if(!p_getc(&(temp_mapscr->warparrivalx),f))
17113 return qe_invalid;
17114
1/2
✓ Branch 0 taken 12671 times.
✗ Branch 1 not taken.
12671 if(!p_getc(&(temp_mapscr->warparrivaly),f))
17115 return qe_invalid;
17116 12671 }
17117
2/2
✓ Branch 0 taken 164316 times.
✓ Branch 1 taken 28388 times.
192704 if(scr_has_flags & SCRHAS_LAYERS)
17118 {
17119
2/2
✓ Branch 0 taken 170328 times.
✓ Branch 1 taken 28388 times.
198716 for(int32_t k=0; k<6; k++)
17120 {
17121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170328 times.
170328 if(!p_getc(&(temp_mapscr->layermap[k]),f))
17122 return qe_invalid;
17123 170328 }
17124
2/2
✓ Branch 0 taken 170328 times.
✓ Branch 1 taken 28388 times.
198716 for(int32_t k=0; k<6; k++)
17125 {
17126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170328 times.
170328 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
17127 return qe_invalid;
17128 170328 }
17129
2/2
✓ Branch 0 taken 170328 times.
✓ Branch 1 taken 28388 times.
198716 for(int32_t k=0; k<6; k++)
17130 {
17131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170328 times.
170328 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
17132 return qe_invalid;
17133 170328 }
17134
1/2
✓ Branch 0 taken 28388 times.
✗ Branch 1 not taken.
28388 if(!p_getc(&(temp_mapscr->hidelayers),f))
17135 return qe_invalid;
17136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28388 times.
28388 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
17137 return qe_invalid;
17138 28388 }
17139
2/2
✓ Branch 0 taken 192600 times.
✓ Branch 1 taken 104 times.
192704 if(scr_has_flags & SCRHAS_MAZE)
17140 {
17141
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 104 times.
520 for(int32_t k=0; k<4; k++)
17142 {
17143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 416 times.
416 if(!p_getc(&(temp_mapscr->path[k]),f))
17144 return qe_invalid;
17145 416 }
17146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(!p_getc(&(temp_mapscr->exitdir),f))
17147 return qe_invalid;
17148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (version >= 32)
17149 {
17150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if (!p_getc(&temp_mapscr->maze_transition_wipe, f))
17151 return qe_invalid;
17152 104 }
17153 104 }
17154
2/2
✓ Branch 0 taken 147768 times.
✓ Branch 1 taken 44936 times.
192704 if(scr_has_flags & SCRHAS_D_S_U)
17155 {
17156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147768 times.
147768 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
17157 return qe_invalid;
17158
2/2
✓ Branch 0 taken 591072 times.
✓ Branch 1 taken 147768 times.
738840 for(int32_t k=0; k<4; k++)
17159 {
17160
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 591072 times.
591072 if(!p_getc(&(temp_mapscr->door[k]),f))
17161 return qe_invalid;
17162
3/4
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 590712 times.
✓ Branch 2 taken 360 times.
✗ Branch 3 not taken.
591072 if(version < 29 && temp_mapscr->door[k] == dNONE)
17163 temp_mapscr->door[k] = dWALL;
17164 591072 }
17165
17166
1/2
✓ Branch 0 taken 147768 times.
✗ Branch 1 not taken.
147768 if(!p_getc(&(temp_mapscr->stairx),f))
17167 return qe_invalid;
17168
17169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147768 times.
147768 if(!p_getc(&(temp_mapscr->stairy),f))
17170 return qe_invalid;
17171
1/2
✓ Branch 0 taken 147768 times.
✗ Branch 1 not taken.
147768 if(!p_igetw(&(temp_mapscr->undercombo),f))
17172 return qe_invalid;
17173
1/2
✓ Branch 0 taken 147768 times.
✗ Branch 1 not taken.
147768 if(!p_getc(&(temp_mapscr->undercset),f))
17174 return qe_invalid;
17175 147768 }
17176
2/2
✓ Branch 0 taken 10488 times.
✓ Branch 1 taken 34448 times.
44936 else if(version < 29)
17177 {
17178
2/2
✓ Branch 0 taken 41952 times.
✓ Branch 1 taken 10488 times.
52440 for(int k = 0; k < 4; ++k)
17179 41952 temp_mapscr->door[k] = dWALL;
17180 10488 }
17181
2/2
✓ Branch 0 taken 177921 times.
✓ Branch 1 taken 14783 times.
192704 if(scr_has_flags & SCRHAS_FLAGS)
17182 {
17183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14783 times.
14783 if(!p_getc(&(temp_mapscr->flags),f))
17184 return qe_invalid;
17185
1/2
✓ Branch 0 taken 14783 times.
✗ Branch 1 not taken.
14783 if(!p_getc(&(temp_mapscr->flags2),f))
17186 return qe_invalid;
17187
1/2
✓ Branch 0 taken 14783 times.
✗ Branch 1 not taken.
14783 if(!p_getc(&(temp_mapscr->flags3),f))
17188 return qe_invalid;
17189
1/2
✓ Branch 0 taken 14783 times.
✗ Branch 1 not taken.
14783 if(!p_getc(&(temp_mapscr->flags4),f))
17190 return qe_invalid;
17191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14783 times.
14783 if(!p_getc(&(temp_mapscr->flags5),f))
17192 return qe_invalid;
17193
1/2
✓ Branch 0 taken 14783 times.
✗ Branch 1 not taken.
14783 if(!p_getc(&(temp_mapscr->flags6),f))
17194 return qe_invalid;
17195
1/2
✓ Branch 0 taken 14783 times.
✗ Branch 1 not taken.
14783 if(!p_getc(&(temp_mapscr->flags7),f))
17196 return qe_invalid;
17197
1/2
✓ Branch 0 taken 14783 times.
✗ Branch 1 not taken.
14783 if(!p_getc(&(temp_mapscr->flags8),f))
17198 return qe_invalid;
17199
1/2
✓ Branch 0 taken 14783 times.
✗ Branch 1 not taken.
14783 if(!p_getc(&(temp_mapscr->flags9),f))
17200 return qe_invalid;
17201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14783 times.
14783 if(!p_getc(&(temp_mapscr->flags10),f))
17202 return qe_invalid;
17203
1/2
✓ Branch 0 taken 14783 times.
✗ Branch 1 not taken.
14783 if(!p_getc(&(temp_mapscr->flags11),f))
17204 return qe_invalid;
17205 14783 }
17206
2/2
✓ Branch 0 taken 179133 times.
✓ Branch 1 taken 13571 times.
192704 if(scr_has_flags & SCRHAS_ENEMY)
17207 {
17208
2/2
✓ Branch 0 taken 135710 times.
✓ Branch 1 taken 13571 times.
149281 for(int32_t k=0; k<10; k++)
17209 {
17210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135710 times.
135710 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
17211 return qe_invalid;
17212
1/2
✓ Branch 0 taken 135710 times.
✗ Branch 1 not taken.
135710 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17213 temp_mapscr->enemy[k] = 0;
17214 135710 }
17215
1/2
✓ Branch 0 taken 13571 times.
✗ Branch 1 not taken.
13571 if(!p_getc(&(temp_mapscr->pattern),f))
17216 return qe_invalid;
17217 13571 }
17218
2/2
✓ Branch 0 taken 153374 times.
✓ Branch 1 taken 39330 times.
192704 if(scr_has_flags & SCRHAS_CARRY)
17219 {
17220
2/2
✓ Branch 0 taken 322 times.
✓ Branch 1 taken 153052 times.
153374 if(version < 34)
17221 {
17222 word tmpw;
17223
1/2
✓ Branch 0 taken 322 times.
✗ Branch 1 not taken.
322 if(!p_igetw(&tmpw,f))
17224 return qe_invalid;
17225 322 temp_mapscr->noreset = tmpw | mLIGHTBEAM | mTMPNORET | mVISITED;
17226
1/2
✓ Branch 0 taken 322 times.
✗ Branch 1 not taken.
322 if(!p_igetw(&tmpw,f))
17227 return qe_invalid;
17228 644 temp_mapscr->nocarry = tmpw | mLIGHTBEAM | mTMPNORET | mVISITED |
17229 322 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
17230 322 }
17231 else
17232 {
17233
1/2
✓ Branch 0 taken 153052 times.
✗ Branch 1 not taken.
153052 if(!p_igetl(&(temp_mapscr->noreset),f))
17234 return qe_invalid;
17235
1/2
✓ Branch 0 taken 153052 times.
✗ Branch 1 not taken.
153052 if(!p_igetl(&(temp_mapscr->nocarry),f))
17236 return qe_invalid;
17237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153052 times.
153052 if(!p_igetl(&(temp_mapscr->exstate_reset),f))
17238 return qe_invalid;
17239
1/2
✓ Branch 0 taken 153052 times.
✗ Branch 1 not taken.
153052 if(!p_igetl(&(temp_mapscr->exstate_carry),f))
17240 return qe_invalid;
17241 }
17242
1/2
✓ Branch 0 taken 153374 times.
✗ Branch 1 not taken.
153374 if(!p_getc(&(temp_mapscr->nextmap),f))
17243 return qe_invalid;
17244
1/2
✓ Branch 0 taken 153374 times.
✗ Branch 1 not taken.
153374 if(!p_getc(&(temp_mapscr->nextscr),f))
17245 return qe_invalid;
17246 153374 }
17247 else
17248 {
17249
2/2
✓ Branch 0 taken 724 times.
✓ Branch 1 taken 38606 times.
39330 if(version < 34)
17250 {
17251 38606 temp_mapscr->noreset = mLIGHTBEAM | mTMPNORET | mVISITED;
17252 38606 temp_mapscr->nocarry = mLIGHTBEAM | mTMPNORET | mVISITED |
17253 mDOOR_UP | mDOOR_DOWN | mDOOR_LEFT | mDOOR_RIGHT | mNEVERRET | mNO_ENEMIES_RETURN;
17254 38606 }
17255 }
17256
2/2
✓ Branch 0 taken 191987 times.
✓ Branch 1 taken 717 times.
192704 if(scr_has_flags & SCRHAS_SCRIPT)
17257 {
17258
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if(!p_igetw(&(temp_mapscr->script),f))
17259 return qe_invalid;
17260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 717 times.
717 if(!p_getc(&(temp_mapscr->preloadscript),f))
17261 return qe_invalid;
17262
2/2
✓ Branch 0 taken 5736 times.
✓ Branch 1 taken 717 times.
6453 for ( int32_t q = 0; q < 8; q++ )
17263 {
17264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5736 times.
5736 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
17265 return qe_invalid;
17266 5736 }
17267 717 }
17268
2/2
✓ Branch 0 taken 153192 times.
✓ Branch 1 taken 39512 times.
192704 if(scr_has_flags & SCRHAS_SECRETS)
17269 {
17270
2/2
✓ Branch 0 taken 5057536 times.
✓ Branch 1 taken 39512 times.
5097048 for(int32_t k=0; k<128; k++)
17271 {
17272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5057536 times.
5057536 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
17273 return qe_invalid;
17274 5057536 }
17275
2/2
✓ Branch 0 taken 5057536 times.
✓ Branch 1 taken 39512 times.
5097048 for(int32_t k=0; k<128; k++)
17276 {
17277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5057536 times.
5057536 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
17278 return qe_invalid;
17279 5057536 }
17280
2/2
✓ Branch 0 taken 5057536 times.
✓ Branch 1 taken 39512 times.
5097048 for(int32_t k=0; k<128; k++)
17281 {
17282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5057536 times.
5057536 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
17283 return qe_invalid;
17284 5057536 }
17285 39512 }
17286
2/2
✓ Branch 0 taken 74243 times.
✓ Branch 1 taken 118461 times.
192704 if(scr_has_flags & SCRHAS_COMBOFLAG)
17287 {
17288
2/2
✓ Branch 0 taken 20849136 times.
✓ Branch 1 taken 118461 times.
20967597 for(int32_t k=0; k<176; ++k)
17289 {
17290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20849136 times.
20849136 if(!p_igetw(&(temp_mapscr->data[k]),f))
17291 return qe_invalid;
17292 20849136 }
17293
2/2
✓ Branch 0 taken 20849136 times.
✓ Branch 1 taken 118461 times.
20967597 for(int32_t k=0; k<176; ++k)
17294 {
17295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20849136 times.
20849136 if(!p_getc(&(temp_mapscr->sflag[k]),f))
17296 return qe_invalid;
17297 20849136 }
17298
2/2
✓ Branch 0 taken 20849136 times.
✓ Branch 1 taken 118461 times.
20967597 for(int32_t k=0; k<176; ++k)
17299 {
17300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20849136 times.
20849136 if(!p_getc(&(temp_mapscr->cset[k]),f))
17301 return qe_invalid;
17302 20849136 }
17303 118461 }
17304
1/2
✓ Branch 0 taken 192704 times.
✗ Branch 1 not taken.
192704 if(scr_has_flags & SCRHAS_MISC)
17305 {
17306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192704 times.
192704 if(!p_igetw(&(temp_mapscr->color),f))
17307 return qe_invalid;
17308
1/2
✓ Branch 0 taken 192704 times.
✗ Branch 1 not taken.
192704 if(!p_getc(&(temp_mapscr->csensitive),f))
17309 return qe_invalid;
17310
1/2
✓ Branch 0 taken 192704 times.
✗ Branch 1 not taken.
192704 if(!p_getc(&(temp_mapscr->oceansfx),f))
17311 return qe_invalid;
17312
1/2
✓ Branch 0 taken 192704 times.
✗ Branch 1 not taken.
192704 if(!p_getc(&(temp_mapscr->bosssfx),f))
17313 return qe_invalid;
17314
1/2
✓ Branch 0 taken 192704 times.
✗ Branch 1 not taken.
192704 if(!p_getc(&(temp_mapscr->secretsfx),f))
17315 return qe_invalid;
17316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192704 times.
192704 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17317 return qe_invalid;
17318
1/2
✓ Branch 0 taken 192704 times.
✗ Branch 1 not taken.
192704 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17319 return qe_invalid;
17320
1/2
✓ Branch 0 taken 192704 times.
✗ Branch 1 not taken.
192704 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17321 return qe_invalid;
17322
1/2
✓ Branch 0 taken 192704 times.
✗ Branch 1 not taken.
192704 if(!p_getc(&(temp_mapscr->lens_layer),f))
17323 return qe_invalid;
17324
2/2
✓ Branch 0 taken 10578 times.
✓ Branch 1 taken 182126 times.
192704 if(version > 27)
17325 {
17326
1/2
✓ Branch 0 taken 182126 times.
✗ Branch 1 not taken.
182126 if(!p_getc(&(temp_mapscr->lens_show),f))
17327 return qe_invalid;
17328
1/2
✓ Branch 0 taken 182126 times.
✗ Branch 1 not taken.
182126 if(!p_getc(&(temp_mapscr->lens_hide),f))
17329 return qe_invalid;
17330 182126 }
17331 192704 }
17332 else
17333 {
17334 temp_mapscr->screen_midi = -1;
17335 temp_mapscr->csensitive = 1;
17336 }
17337 //FFC
17338 192704 bool old_ff = version < 25;
17339 192704 dword bits = 0;
17340 192704 word numffc = 32;
17341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192704 times.
192704 if(old_ff)
17342 {
17343 if(!p_igetl(&bits,f))
17344 return qe_invalid;
17345 }
17346 else
17347 {
17348
2/4
✓ Branch 0 taken 192704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 192704 times.
192704 if(!p_igetw(&numffc,f) || numffc > MAXFFCS)
17349 return qe_invalid;
17350 }
17351
17352 192704 temp_mapscr->ffcCountMarkDirty();
17353 192704 temp_mapscr->ffcs.clear();
17354 192704 temp_mapscr->resizeFFC(numffc);
17355
17356 byte tempbyte;
17357 word tempw;
17358
4/6
✓ Branch 0 taken 171 times.
✓ Branch 1 taken 192533 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 171 times.
✓ Branch 4 taken 171 times.
✗ Branch 5 not taken.
192704 static ffcdata nil_ffc;
17359
2/2
✓ Branch 0 taken 1995806 times.
✓ Branch 1 taken 192704 times.
2188510 for(word m = 0; m < numffc; ++m)
17360 {
17361
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1995806 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1995806 if(old_ff && !(bits & (1<<m))) continue;
17362
17363
1/2
✓ Branch 0 taken 1995806 times.
✗ Branch 1 not taken.
1995806 ffcdata& tempffc = (m < MAXFFCS)
17364 1995806 ? temp_mapscr->ffcs[m]
17365 : nil_ffc; //sanity
17366
17367
1/2
✓ Branch 0 taken 1995806 times.
✗ Branch 1 not taken.
1995806 if(!p_igetw(&tempw,f))
17368 return qe_invalid;
17369
3/4
✓ Branch 0 taken 1995806 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27723 times.
✓ Branch 3 taken 1968083 times.
1995806 if(!old_ff && !tempw) //empty ffc, nothing more to load
17370 1968083 continue;
17371 27723 tempffc.data = tempw;
17372
17373
1/2
✓ Branch 0 taken 27723 times.
✗ Branch 1 not taken.
27723 if(!p_getc(&(tempffc.cset),f))
17374 return qe_invalid;
17375
1/2
✓ Branch 0 taken 27723 times.
✗ Branch 1 not taken.
27723 if(!p_igetw(&(tempffc.delay),f))
17376 return qe_invalid;
17377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27723 times.
27723 if(!p_igetzf(&(tempffc.x),f))
17378 return qe_invalid;
17379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27723 times.
27723 if(!p_igetzf(&(tempffc.y),f))
17380 return qe_invalid;
17381
1/2
✓ Branch 0 taken 27723 times.
✗ Branch 1 not taken.
27723 if(!p_igetzf(&(tempffc.vx),f))
17382 return qe_invalid;
17383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27723 times.
27723 if(!p_igetzf(&(tempffc.vy),f))
17384 return qe_invalid;
17385
1/2
✓ Branch 0 taken 27723 times.
✗ Branch 1 not taken.
27723 if(!p_igetzf(&(tempffc.ax),f))
17386 return qe_invalid;
17387
1/2
✓ Branch 0 taken 27723 times.
✗ Branch 1 not taken.
27723 if(!p_igetzf(&(tempffc.ay),f))
17388 return qe_invalid;
17389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27723 times.
27723 if(!p_getc(&(tempffc.link),f))
17390 return qe_invalid;
17391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27723 times.
27723 if(version < 24)
17392 {
17393 if(!p_getc(&tempbyte,f))
17394 return qe_invalid;
17395 tempffc.hit_width = (tempbyte&0x3F)+1;
17396 tempffc.txsz = (tempbyte>>6)+1;
17397 if(!p_getc(&tempbyte,f))
17398 return qe_invalid;
17399 tempffc.hit_height = (tempbyte&0x3F)+1;
17400 tempffc.tysz = (tempbyte>>6)+1;
17401 }
17402 else
17403 {
17404
1/2
✓ Branch 0 taken 27723 times.
✗ Branch 1 not taken.
27723 if(!p_igetl(&(tempffc.hit_width),f))
17405 return qe_invalid;
17406
1/2
✓ Branch 0 taken 27723 times.
✗ Branch 1 not taken.
27723 if(!p_igetl(&(tempffc.hit_height),f))
17407 return qe_invalid;
17408
1/2
✓ Branch 0 taken 27723 times.
✗ Branch 1 not taken.
27723 if(!p_getc(&(tempffc.txsz),f))
17409 return qe_invalid;
17410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27723 times.
27723 if(!p_getc(&(tempffc.tysz),f))
17411 return qe_invalid;
17412 }
17413
1/2
✓ Branch 0 taken 27723 times.
✗ Branch 1 not taken.
27723 if(!p_igetl(&(tempffc.flags),f))
17414 return qe_invalid;
17415 27723 tempffc.updateSolid();
17416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27723 times.
27723 if(!p_igetw(&(tempffc.script),f))
17417 return qe_invalid;
17418
2/2
✓ Branch 0 taken 221784 times.
✓ Branch 1 taken 27723 times.
249507 for(auto q = 0; q < 8; ++q)
17419 {
17420
1/2
✓ Branch 0 taken 221784 times.
✗ Branch 1 not taken.
221784 if(!p_igetl(&(tempffc.initd[q]),f))
17421 return qe_invalid;
17422 221784 }
17423
2/2
✓ Branch 0 taken 7633 times.
✓ Branch 1 taken 20090 times.
27723 if(version < 33)
17424 {
17425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7633 times.
7633 if(!p_getc(&(tempbyte),f))
17426 return qe_invalid;
17427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7633 times.
7633 if(!p_getc(&(tempbyte),f))
17428 return qe_invalid;
17429 7633 }
17430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20090 times.
20090 else if(!p_getc(&(tempffc.layer),f))
17431 return qe_invalid;
17432
17433
1/2
✓ Branch 0 taken 27723 times.
✗ Branch 1 not taken.
27723 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17434 {
17435 tempffc.script = 0;
17436 for(int q = 0; q < 8; ++q)
17437 tempffc.initd[q] = 0;
17438 }
17439 27723 }
17440 //END FFC
17441
2/2
✓ Branch 0 taken 38497 times.
✓ Branch 1 taken 154207 times.
192704 if(version > 29)
17442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154207 times.
154207 if(!p_getlstr(&temp_mapscr->usr_notes, f))
17443 return qe_invalid;
17444
17445
4/4
✓ Branch 0 taken 67496 times.
✓ Branch 1 taken 125208 times.
✓ Branch 2 taken 67394 times.
✓ Branch 3 taken 102 times.
192704 if (version >= 35 && (temp_mapscr->flags10 & fSCREEN_GRAVITY))
17446 {
17447
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (!p_igetzf(&temp_mapscr->screen_gravity, f))
17448 return qe_invalid;
17449
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (!p_igetzf(&temp_mapscr->screen_terminal_v, f))
17450 return qe_invalid;
17451 102 }
17452 }
17453
17454 1371560 temp_mapscr->shrinkToFitFFCs();
17455
17456 1371560 return 0;
17457 1558296 }
17458
17459 491 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17460 {
17461
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 24 times.
491 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
17462 491 int32_t screen=0;
17463
17464 491 word version=0;
17465 dword dummy;
17466 int32_t screens_to_read;
17467
17468 491 mapscr temp_mapscr{};
17469 word temp_map_count;
17470 dword section_size;
17471
17472
5/6
✓ Branch 0 taken 473 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 467 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
491 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17473 {
17474 18 screens_to_read=MAPSCRS192b136;
17475 18 }
17476 else
17477 {
17478 473 screens_to_read=MAPSCRS;
17479 }
17480
17481
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 24 times.
491 if(Header->zelda_version > 0x192)
17482 {
17483 //section version info
17484
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
467 if(!p_igetw(&version,f))
17485 {
17486 return qe_invalid;
17487 }
17488
17489
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if (version > V_MAPS)
17490 return qe_version;
17491
17492 467 FFCore.quest_format[vMaps] = version;
17493
17494
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
467 if(!p_igetw(&dummy,f))
17495 {
17496 return qe_invalid;
17497 }
17498
17499 //section size
17500
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
467 if(!p_igetl(&section_size,f))
17501 {
17502 return qe_invalid;
17503 }
17504
17505 //finally... section data
17506
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
467 if(!p_igetw(&temp_map_count,f))
17507 {
17508 return 5;
17509 }
17510 467 }
17511 else
17512 {
17513 24 temp_map_count=map_count;
17514 }
17515
17516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 491 times.
491 if (temp_map_count > MAXMAPS)
17517 {
17518 return qe_invalid;
17519 }
17520
17521
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 1 times.
491 if (!should_skip)
17522 {
17523 490 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17524 490 TheMaps.clear();
17525
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 TheMaps.resize(_mapsSize);
17526 490 old_combo_pages.clear();
17527
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 old_combo_pages.resize(_mapsSize);
17528 490 map_infos.clear();
17529
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 map_infos.resize(temp_map_count);
17530
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 163 times.
490 if(version >= 31)
17531 163 Regions = {};
17532 490 }
17533
17534
4/4
✓ Branch 0 taken 491 times.
✓ Branch 1 taken 12876 times.
✓ Branch 2 taken 12876 times.
✓ Branch 3 taken 491 times.
13367 for(int32_t i=0; i<temp_map_count && i<MAXMAPS; i++)
17535 {
17536 12876 byte valid=1;
17537
2/2
✓ Branch 0 taken 4203 times.
✓ Branch 1 taken 8673 times.
12876 if(version > 22)
17538 {
17539
2/4
✓ Branch 0 taken 4203 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4203 times.
✗ Branch 3 not taken.
4203 if(!p_getc(&valid,f))
17540 return qe_invalid;
17541 4203 }
17542
2/2
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 11463 times.
12876 if(valid)
17543 {
17544
2/2
✓ Branch 0 taken 8803 times.
✓ Branch 1 taken 2660 times.
11463 if (version > 25)
17545 {
17546 2660 auto& mapinf = map_infos[i];
17547
2/2
✓ Branch 0 taken 15960 times.
✓ Branch 1 taken 2660 times.
18620 for(int q = 0; q < 6; ++q)
17548 {
17549
2/4
✓ Branch 0 taken 15960 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15960 times.
✗ Branch 3 not taken.
15960 if(!p_igetw(&mapinf.autolayers[q],f))
17550 return qe_invalid;
17551 15960 }
17552
2/2
✓ Branch 0 taken 926 times.
✓ Branch 1 taken 1734 times.
2660 if (version >= 36)
17553
2/4
✓ Branch 0 taken 926 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 926 times.
✗ Branch 3 not taken.
926 if(!p_igetw(&mapinf.autopalette,f))
17554 return qe_invalid;
17555 2660 }
17556
17557
2/2
✓ Branch 0 taken 9245 times.
✓ Branch 1 taken 2218 times.
11463 if (version >= 31)
17558 {
17559 static regions_data tmp_rd;
17560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2218 times.
2218 regions_data& rd = should_skip ? tmp_rd : Regions[i];
17561
2/2
✓ Branch 0 taken 17744 times.
✓ Branch 1 taken 2218 times.
19962 for(int32_t j=0; j<8; j++)
17562 {
17563
2/2
✓ Branch 0 taken 141952 times.
✓ Branch 1 taken 17744 times.
159696 for(int32_t k=0; k<8; k++)
17564 {
17565
2/4
✓ Branch 0 taken 141952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 141952 times.
✗ Branch 3 not taken.
141952 if(!p_getc(&rd.region_ids[j][k],f))
17566 {
17567 return qe_invalid;
17568 }
17569 141952 }
17570 17744 }
17571 2218 }
17572 11463 }
17573
2/2
✓ Branch 0 taken 1750464 times.
✓ Branch 1 taken 12876 times.
1763340 for(int32_t j=0; j<screens_to_read; j++)
17574 {
17575 1750464 screen=i*MAPSCRS+j;
17576
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 1750192 times.
1750464 mapscr* scr = should_skip ? &temp_mapscr : &TheMaps[screen];
17577 1750464 scr->map = i;
17578 1750464 scr->screen = j;
17579
2/2
✓ Branch 0 taken 1558296 times.
✓ Branch 1 taken 192168 times.
1750464 if(valid)
17580
1/2
✓ Branch 0 taken 1558296 times.
✗ Branch 1 not taken.
1558296 readmapscreen(f, Header, scr, version, screen);
17581
1/2
✓ Branch 0 taken 192168 times.
✗ Branch 1 not taken.
192168 else if (!should_skip)
17582
1/2
✓ Branch 0 taken 192168 times.
✗ Branch 1 not taken.
192168 clear_screen(scr);
17583 1750464 }
17584
17585
2/2
✓ Branch 0 taken 12874 times.
✓ Branch 1 taken 2 times.
12876 if (should_skip)
17586 2 continue;
17587
17588
5/6
✓ Branch 0 taken 12706 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 12688 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
12874 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17589 {
17590 168 int32_t index = (i*MAPSCRS+132);
17591
17592
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 TheMaps[index]=TheMaps[index-1];
17593
17594 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17595 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17596 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17597
17598
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 168 times.
672 for(int32_t j=133; j<MAPSCRS; j++)
17599 {
17600 504 screen=i*MAPSCRS+j;
17601
17602
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 TheMaps[screen].zero_memory();
17603 504 TheMaps[screen].valid = mVERSION;
17604 504 TheMaps[screen].screen_midi = -1;
17605 504 TheMaps[screen].csensitive = 1;
17606 504 }
17607 168 }
17608
17609
5/6
✓ Branch 0 taken 12706 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 12688 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
12874 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17610 {
17611
2/2
✓ Branch 0 taken 22848 times.
✓ Branch 1 taken 168 times.
23016 for(int32_t j=0; j<MAPSCRS; j++)
17612 {
17613 22848 screen=i*MAPSCRS+j;
17614
1/2
✓ Branch 0 taken 22848 times.
✗ Branch 1 not taken.
22848 TheMaps[screen].door_combo_set=MakeDoors(i, j);
17615
17616
2/2
✓ Branch 0 taken 2924544 times.
✓ Branch 1 taken 22848 times.
2947392 for(int32_t k=0; k<128; k++)
17617 {
17618
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcset[k]=tcmbcset2(i, TheMaps[screen].secretcombo[k]);
17619
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretflag[k]=tcmbflag2(i, TheMaps[screen].secretcombo[k]);
17620
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[screen].secretcombo[k]=tcmbdat2(i, j, TheMaps[screen].secretcombo[k]);
17621 2924544 }
17622 22848 }
17623 168 }
17624 12874 }
17625 491 map_count = temp_map_count;
17626 491 return 0;
17627 491 }
17628
17629
17630 9204156 void update_combo(newcombo& cmb, word section_version)
17631 {
17632
2/2
✓ Branch 0 taken 1522137 times.
✓ Branch 1 taken 7682019 times.
9204156 if(section_version < 40)
17633 {
17634
3/3
✓ Branch 0 taken 5144 times.
✓ Branch 1 taken 45418 times.
✓ Branch 2 taken 7631457 times.
7682019 switch(cmb.type)
17635 {
17636 case cWATER: case cSHALLOWWATER:
17637 45418 cmb.attribytes[6] = iwRipples;
17638 45418 break;
17639 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17640 5144 cmb.attribytes[6] = iwTallGrass;
17641 5144 break;
17642 }
17643 7682019 }
17644
2/2
✓ Branch 0 taken 1174706 times.
✓ Branch 1 taken 8029450 times.
9204156 if(section_version < 49)
17645 {
17646
4/4
✓ Branch 0 taken 7994679 times.
✓ Branch 1 taken 34771 times.
✓ Branch 2 taken 15455 times.
✓ Branch 3 taken 7979224 times.
8029450 if(cmb.type == cWATER || cmb.type == cSHALLOWWATER)
17647 50226 cmb.sfx_landing = WAV_ZN1SPLASH;
17648 8029450 }
17649 9204156 }
17650 288 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17651 {
17652
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 24 times.
288 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17653 byte tempbyte;
17654
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 287 times.
288 if (!should_skip)
17655 {
17656 287 reset_all_combo_animations();
17657 287 init_combo_classes();
17658 287 }
17659
17660 // combos
17661 288 word combos_used=0;
17662 int32_t dummy;
17663 byte padding;
17664 288 newcombo temp_combo;
17665
17666
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 287 times.
288 if (!should_skip)
17667
2/2
✓ Branch 0 taken 18735360 times.
✓ Branch 1 taken 287 times.
18735647 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17668
1/2
✓ Branch 0 taken 18735360 times.
✗ Branch 1 not taken.
18735647 combobuf[q].clear();
17669
17670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(version < 0x174)
17671 {
17672 combos_used=1024;
17673 }
17674
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 18 times.
288 else if(version < 0x191)
17675 {
17676 18 combos_used=2048;
17677 18 }
17678 else
17679 {
17680
2/4
✓ Branch 0 taken 270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
270 if(!p_igetw(&combos_used,f))
17681 {
17682 return qe_invalid;
17683 }
17684 }
17685
17686 //finally... section data
17687
2/2
✓ Branch 0 taken 7547003 times.
✓ Branch 1 taken 288 times.
7547291 for(int32_t i=0; i<combos_used; i++)
17688 {
17689
1/2
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
7547003 temp_combo.clear();
17690
1/2
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
7547003 combo_trigger& temp_trigger = temp_combo.triggers.emplace_back();
17691 7547003 int32_t temp_trigflags[6] = {0};
17692
17693
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if ( section_version >= 11 )
17694 {
17695
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.tile,f))
17696 {
17697 return qe_invalid;
17698 }
17699 202968 }
17700 else
17701 {
17702
2/4
✓ Branch 0 taken 7344035 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7344035 times.
✗ Branch 3 not taken.
7344035 if(!p_igetw(&temp_combo.tile,f))
17703 {
17704 return qe_invalid;
17705 }
17706 }
17707 7547003 temp_combo.o_tile = temp_combo.tile;
17708
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.flip,f))
17709 {
17710 return qe_invalid;
17711 }
17712
17713
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.walk,f))
17714 {
17715 return qe_invalid;
17716 }
17717
17718
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.type,f))
17719 {
17720 return qe_invalid;
17721 }
17722
17723
2/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7547003 times.
✗ Branch 3 not taken.
7547003 if(!p_getc(&temp_combo.csets,f))
17724 {
17725 return qe_invalid;
17726 }
17727
17728
2/2
✓ Branch 0 taken 69774 times.
✓ Branch 1 taken 7477229 times.
7547003 if(version < 0x193)
17729 {
17730
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17731 return qe_invalid;
17732
17733
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17734 return qe_invalid;
17735
17736
2/2
✓ Branch 0 taken 32910 times.
✓ Branch 1 taken 36864 times.
69774 if(version < 0x192)
17737 {
17738
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if(version == 0x191)
17739 {
17740 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17741 {
17742 if(!p_getc(&padding,f))
17743 return qe_invalid;
17744 }
17745 }
17746 36864 }
17747 69774 }
17748
2/2
✓ Branch 0 taken 7510139 times.
✓ Branch 1 taken 36864 times.
7547003 if(version >= 0x192)
17749 {
17750
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_getc(&temp_combo.frames,f))
17751 return qe_invalid;
17752
17753
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_getc(&temp_combo.speed,f))
17754 return qe_invalid;
17755
17756
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_igetw(&temp_combo.nextcombo,f))
17757 return qe_invalid;
17758
17759
2/4
✓ Branch 0 taken 7510139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7510139 times.
✗ Branch 3 not taken.
7510139 if(!p_getc(&temp_combo.nextcset,f))
17760 return qe_invalid;
17761
17762 //Base flag
17763
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=3)
17764
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.flag,f))
17765 return qe_invalid;
17766
17767
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=4)
17768 {
17769
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.skipanim,f))
17770 return qe_invalid;
17771
17772
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_igetw(&temp_combo.nexttimer,f))
17773 return qe_invalid;
17774 4621731 }
17775
17776
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=5)
17777
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.skipanimy,f))
17778 return qe_invalid;
17779
17780
2/2
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2888408 times.
7510139 if(section_version>=6)
17781 {
17782
2/4
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4621731 times.
✗ Branch 3 not taken.
4621731 if(!p_getc(&temp_combo.animflags,f))
17783 return qe_invalid;
17784
17785
1/2
✓ Branch 0 taken 4621731 times.
✗ Branch 1 not taken.
4621731 if(section_version == 6)
17786 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17787 4621731 }
17788
17789
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=8) //combo Attributes[4] and userflags.
17790 {
17791
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 811872 times.
1014840 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17792
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_igetl(&temp_combo.attributes[q],f))
17793 return qe_invalid;
17794
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.usrflags,f))
17795 return qe_invalid;
17796
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 if(section_version >= 20)
17797
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.genflags,f))
17798 return qe_invalid;
17799 202968 }
17800
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version>=10) //combo trigger flags
17801 {
17802
2/2
✓ Branch 0 taken 608904 times.
✓ Branch 1 taken 202968 times.
811872 for ( int32_t q = 0; q < 3; q++ )
17803
2/4
✓ Branch 0 taken 608904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 608904 times.
✗ Branch 3 not taken.
608904 if(!p_igetl(&temp_trigflags[q],f))
17804 return qe_invalid;
17805 202968 }
17806
1/2
✓ Branch 0 taken 7307171 times.
✗ Branch 1 not taken.
7307171 else if(section_version==9) //combo trigger flags, V9 only had two indices
17807 {
17808 for ( int32_t q = 0; q < 2; q++ )
17809 if(!p_igetl(&temp_trigflags[q],f))
17810 return qe_invalid;
17811 }
17812
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version >= 9)
17813
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_trigger.triggerlevel,f))
17814 return qe_invalid;
17815
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version >= 22)
17816
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_trigger.triggerbtn,f))
17817 return qe_invalid;
17818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 24)
17819 {
17820 if(!p_getc(&temp_trigger.triggeritem,f))
17821 return qe_invalid;
17822 if(!p_getc(&tempbyte, f))
17823 return qe_invalid;
17824 temp_trigger.trigtimer = tempbyte;
17825 }
17826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 25)
17827 if(!p_getc(&temp_trigger.trigsfx,f))
17828 return qe_invalid;
17829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 27)
17830 if(!p_igetl(&temp_trigger.trigchange,f))
17831 return qe_invalid;
17832
17833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 29)
17834 {
17835 if(!p_igetw(&temp_trigger.trigprox,f))
17836 return qe_invalid;
17837 if(!p_getc(&tempbyte,f))
17838 return qe_invalid;
17839 temp_trigger.trigctr = tempbyte;
17840 if(!p_igetl(&temp_trigger.trigctramnt,f))
17841 return qe_invalid;
17842 }
17843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 30)
17844 if(!p_getc(&temp_trigger.triglbeam,f))
17845 return qe_invalid;
17846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 31)
17847 {
17848 if(!p_getc(&temp_trigger.trigcschange,f))
17849 return qe_invalid;
17850 if(!p_igetw(&temp_trigger.spawnitem,f))
17851 return qe_invalid;
17852 if(!p_igetw(&temp_trigger.spawnenemy,f))
17853 return qe_invalid;
17854 if(!p_getc(&temp_trigger.exstate,f))
17855 return qe_invalid;
17856 if(!p_igetl(&temp_trigger.spawnip,f))
17857 return qe_invalid;
17858 if(!p_getc(&temp_trigger.trigcopycat,f))
17859 return qe_invalid;
17860 }
17861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7510139 times.
7510139 if(section_version >= 32)
17862 if(!p_getc(&temp_trigger.trigcooldown,f))
17863 return qe_invalid;
17864
17865
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=12) //combo label
17866 {
17867 char label[12];
17868 202968 label[11] = '\0';
17869
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 2232648 times.
2435616 for ( int32_t q = 0; q < 11; q++ )
17870
2/4
✓ Branch 0 taken 2232648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2232648 times.
✗ Branch 3 not taken.
2232648 if(!p_getc(&label[q],f))
17871 return qe_invalid;
17872
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 temp_combo.label = label;
17873 202968 }
17874
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=13) //attribytes[4]
17875
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 0; q < 4; q++ )
17876
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17877 202968 return qe_invalid;
17878 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17879 * This fixes a poor implementation of a ->next flag bug thing.
17880 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17881 * there was a version bump a few weeks before a change that broke stuff.
17882 */
17883
3/4
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202968 times.
7510139 if (section_version >= 13 && section_version < 21)
17884 {
17885 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17886 }
17887 //combo scripts
17888
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version>=14)
17889 {
17890
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.script,f))
17891 return qe_invalid;
17892
2/2
✓ Branch 0 taken 405936 times.
✓ Branch 1 taken 202968 times.
608904 for ( int32_t q = 0; q < 2; q++ )
17893
2/4
✓ Branch 0 taken 405936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405936 times.
✗ Branch 3 not taken.
405936 if(!p_igetl(&temp_combo.initd[q],f))
17894 return qe_invalid;
17895 202968 }
17896
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7307171 times.
7510139 if(section_version>=15)
17897 {
17898
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17899
2/2
✓ Branch 0 taken 107633 times.
✓ Branch 1 taken 95335 times.
202968 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17900
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17901
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17902 202968 }
17903
2/2
✓ Branch 0 taken 7307171 times.
✓ Branch 1 taken 202968 times.
7510139 if(section_version>=17) //attribytes[4]
17904 {
17905
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17906
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17907 return qe_invalid;
17908
2/2
✓ Branch 0 taken 1623744 times.
✓ Branch 1 taken 202968 times.
1826712 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17909
2/4
✓ Branch 0 taken 1623744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1623744 times.
✗ Branch 3 not taken.
1623744 if(!p_igetw(&temp_combo.attrishorts[q],f))
17910 return qe_invalid;
17911 202968 }
17912
17913
2/2
✓ Branch 0 taken 7477229 times.
✓ Branch 1 taken 32910 times.
7510139 if(version < 0x193)
17914
2/2
✓ Branch 0 taken 362010 times.
✓ Branch 1 taken 32910 times.
394920 for(int32_t q=0; q<11; q++)
17915
2/4
✓ Branch 0 taken 362010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 362010 times.
✗ Branch 3 not taken.
362010 if(!p_getc(&dummy,f))
17916 32910 return qe_invalid;
17917 7510139 }
17918
17919 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17920
3/6
✓ Branch 0 taken 4621731 times.
✓ Branch 1 taken 2925272 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4621731 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7547003 if((version < 0x211)||((version == 0x211)&&(build<7)))
17921 {
17922
2/2
✓ Branch 0 taken 2885336 times.
✓ Branch 1 taken 39936 times.
2925272 if(!get_qr(qr_NEWENEMYTILES))
17923 {
17924
1/5
✓ Branch 0 taken 39936 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
39936 switch(temp_combo.tile)
17925 {
17926 case 130:
17927 temp_combo.tile = 132;
17928 break;
17929
17930 case 131:
17931 temp_combo.tile = 133;
17932 break;
17933
17934 case 132:
17935 temp_combo.tile = 130;
17936 break;
17937
17938 case 133:
17939 temp_combo.tile = 131;
17940 break;
17941 }
17942 39936 }
17943 2925272 }
17944
17945
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version < 15)
17946 7344035 temp_combo.o_tile = temp_combo.tile;
17947
17948
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version<18) //upper bits for .walk
17949 7344035 temp_combo.walk |= 0xF0;
17950
17951
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version < 19)
17952
2/2
✓ Branch 0 taken 29376140 times.
✓ Branch 1 taken 7344035 times.
36720175 for(int32_t q = 0; q < 4; ++q)
17953 36720175 temp_combo.attributes[q] *= 10000L;
17954
17955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 23)
17956 {
17957
2/2
✓ Branch 0 taken 15235 times.
✓ Branch 1 taken 7531768 times.
7547003 switch(temp_combo.type) //TRIGFLAG_CMBTYPEFX now required for combotype-specific effects
17958 {
17959 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17960 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17961 case cTRIGGERGENERIC: case cCSWITCH:
17962 15235 temp_trigflags[TRIGFLAG_CMBTYPEFX/32] |= 1<<(TRIGFLAG_CMBTYPEFX%32);
17963 15235 }
17964 7547003 }
17965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 25)
17966 {
17967
2/2
✓ Branch 0 taken 27396 times.
✓ Branch 1 taken 7519607 times.
7547003 switch(temp_combo.type)
17968 {
17969 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27396 times.
27396 if(!(temp_combo.usrflags & cflag3))
17971 27396 temp_combo.attribytes[3] = WAV_DOOR;
17972 27396 temp_combo.usrflags &= ~cflag3;
17973 27396 break;
17974 }
17975 7547003 }
17976
17977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 26)
17978
2/2
✓ Branch 0 taken 7545882 times.
✓ Branch 1 taken 1121 times.
7548124 if(temp_combo.type == cARMOS)
17979
1/2
✓ Branch 0 taken 1121 times.
✗ Branch 1 not taken.
1121 if(temp_combo.usrflags & cflag1)
17980 temp_combo.usrflags |= cflag3;
17981
17982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 27)
17983 {
17984
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(temp_trigflags[0] & 0x00040000) //'next'
17985 temp_trigger.trigchange = 1;
17986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 else if(temp_trigflags[0] & 0x00080000) //'prev'
17987 temp_trigger.trigchange = -1;
17988 7547003 else temp_trigger.trigchange = 0;
17989 7547003 temp_trigflags[0] &= ~(0x00040000|0x00080000);
17990 7547003 }
17991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7547003 times.
7547003 if(section_version < 28)
17992 {
17993
2/2
✓ Branch 0 taken 15512 times.
✓ Branch 1 taken 7531491 times.
7547003 switch(temp_combo.type)
17994 {
17995 case cLOCKBLOCK: case cLOCKEDCHEST:
17996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15512 times.
15512 if(temp_combo.usrflags & cflag7)
17997 temp_combo.usrflags |= cflag8;
17998 15512 else temp_combo.usrflags &= ~cflag8;
17999 15512 temp_combo.usrflags &= ~cflag7;
18000 15512 break;
18001 }
18002
2/2
✓ Branch 0 taken 758 times.
✓ Branch 1 taken 7546245 times.
7547003 switch(temp_combo.type)
18003 {
18004 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
18005 758 temp_combo.attrishorts[2] = -1;
18006 758 temp_combo.usrflags |= cflag7;
18007 758 break;
18008 }
18009 7547003 }
18010
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7344035 times.
7547003 if(section_version < 20)
18011 {
18012 7344035 temp_combo.genflags = 0;
18013
2/2
✓ Branch 0 taken 143987 times.
✓ Branch 1 taken 7200048 times.
7344035 switch(temp_combo.type)
18014 {
18015 case cPUSH_WAIT: case cPUSH_HEAVY:
18016 case cPUSH_HW: case cL_STATUE:
18017 case cR_STATUE: case cPUSH_HEAVY2:
18018 case cPUSH_HW2: case cPOUND:
18019 case cC_STATUE: case cMIRROR:
18020 case cMIRRORSLASH: case cMIRRORBACKSLASH:
18021 case cMAGICPRISM: case cMAGICPRISM4:
18022 case cMAGICSPONGE: case cEYEBALL_A:
18023 case cEYEBALL_B: case cEYEBALL_4:
18024 case cBUSH: case cFLOWERS:
18025 case cLOCKBLOCK: case cLOCKBLOCK2:
18026 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
18027 case cCHEST: case cCHEST2:
18028 case cLOCKEDCHEST: case cLOCKEDCHEST2:
18029 case cBOSSCHEST: case cBOSSCHEST2:
18030 case cBUSHNEXT: case cBUSHTOUCHY:
18031 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
18032 case cSIGNPOST: case cCSWITCHBLOCK:
18033 case cTORCH: case cTRIGGERGENERIC:
18034
1/2
✓ Branch 0 taken 143987 times.
✗ Branch 1 not taken.
143987 if(temp_combo.usrflags & cflag16)
18035 {
18036 temp_combo.genflags |= cflag1;
18037 temp_combo.usrflags &= ~cflag16;
18038 }
18039 143987 break;
18040 }
18041 7344035 }
18042
18043
1/2
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
7547003 temp_trigger.trigger_flags.clear();
18044
2/2
✓ Branch 0 taken 7547003 times.
✓ Branch 1 taken 1449024576 times.
1456571579 for(size_t q = 0; q < 32*6; ++q)
18045 {
18046 1449024576 auto ind = q/32;
18047 1449024576 auto bit = 1<<(q%32);
18048
2/2
✓ Branch 0 taken 1449008300 times.
✓ Branch 1 taken 16276 times.
1449024576 if(temp_trigflags[ind] & bit)
18049
1/2
✓ Branch 0 taken 16276 times.
✗ Branch 1 not taken.
16276 temp_trigger.trigger_flags.set(q, true);
18050 1449024576 }
18051
18052
3/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15274 times.
✓ Branch 3 taken 7531729 times.
7547003 if(temp_trigger.is_blank())
18053 7531729 temp_combo.triggers.clear();
18054
18055 7547003 update_combo(temp_combo, section_version);
18056
18057
3/4
✓ Branch 0 taken 7547003 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7532084 times.
✓ Branch 3 taken 14919 times.
7547003 if(i>=start_combo && !should_skip)
18058 {
18059
1/2
✓ Branch 0 taken 7532084 times.
✗ Branch 1 not taken.
7532084 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18060 {
18061 temp_combo.script = 0;
18062 for(int q = 0; q < 8; ++q)
18063 temp_combo.initd[q] = 0;
18064 }
18065
1/2
✓ Branch 0 taken 7532084 times.
✗ Branch 1 not taken.
7532084 combobuf[i] = temp_combo;
18066 7532084 }
18067 7547003 }
18068
18069
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 1 times.
288 if (should_skip)
18070 1 return 0;
18071
18072
5/6
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 264 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
287 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18073 {
18074
2/2
✓ Branch 0 taken 1501440 times.
✓ Branch 1 taken 23 times.
1501463 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18075 {
18076
2/2
✓ Branch 0 taken 1501225 times.
✓ Branch 1 taken 215 times.
1501440 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18077 {
18078 215 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18079 215 }
18080 1501440 }
18081 23 }
18082
18083 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18084
4/6
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 228 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
287 if(version == 0x210 && get_app_id() != App::zquest)
18085 {
18086
2/2
✓ Branch 0 taken 3851520 times.
✓ Branch 1 taken 59 times.
3851579 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18087
2/2
✓ Branch 0 taken 3851335 times.
✓ Branch 1 taken 185 times.
3851705 if(combobuf[tmpcounter].type == cLADDERONLY)
18088 185 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18089 59 }
18090
18091
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 82 times.
287 if(section_version<7)
18092 {
18093
2/2
✓ Branch 0 taken 5352960 times.
✓ Branch 1 taken 82 times.
5353042 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18094 {
18095
6/9
✓ Branch 0 taken 5350008 times.
✓ Branch 1 taken 853 times.
✓ Branch 2 taken 791 times.
✓ Branch 3 taken 603 times.
✓ Branch 4 taken 174 times.
✓ Branch 5 taken 531 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5352960 switch(combobuf[tmpcounter].type)
18096 {
18097 case cSLASH:
18098 853 combobuf[tmpcounter].type=cSLASHTOUCHY;
18099 853 break;
18100
18101 case cSLASHITEM:
18102 791 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18103 791 break;
18104
18105 case cBUSH:
18106 603 combobuf[tmpcounter].type=cBUSHTOUCHY;
18107 603 break;
18108
18109 case cFLOWERS:
18110 174 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18111 174 break;
18112
18113 case cTALLGRASS:
18114 531 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18115 531 break;
18116
18117 case cSLASHNEXT:
18118 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18119 break;
18120
18121 case cSLASHNEXTITEM:
18122 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18123 break;
18124
18125 case cBUSHNEXT:
18126 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18127 break;
18128 }
18129 5352960 }
18130 82 }
18131
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 282 times.
287 if (section_version < 16)
18132 {
18133
2/2
✓ Branch 0 taken 18408960 times.
✓ Branch 1 taken 282 times.
18409242 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18134 {
18135
2/2
✓ Branch 0 taken 18380119 times.
✓ Branch 1 taken 28841 times.
18408960 if (combobuf[tmpcounter].type == cWATER)
18136 {
18137 28841 combobuf[tmpcounter].attributes[0] = 40000L;
18138 28841 }
18139 18408960 }
18140 282 }
18141
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 3 times.
287 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18142 {
18143 3 combobuf[0].walk = 0xF0;
18144 3 combobuf[0].type = 0;
18145 3 combobuf[0].flag = 0;
18146 3 }
18147
18148 //Now for the new combo alias reset
18149
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 82 times.
287 if(section_version<2)
18150 {
18151
2/2
✓ Branch 0 taken 671744 times.
✓ Branch 1 taken 82 times.
671826 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18152 {
18153 671744 combo_aliases[j].width = 0;
18154 671744 combo_aliases[j].height = 0;
18155 671744 combo_aliases[j].layermask = 0;
18156
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].combos.clear();
18157
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].csets.clear();
18158 671744 }
18159 82 }
18160
18161
18162
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 setup_combo_animations();
18163
1/2
✓ Branch 0 taken 287 times.
✗ Branch 1 not taken.
287 setup_combo_animations2();
18164 287 return 0;
18165 288 }
18166
18167 15975 int32_t readcombo_triggers_loop(PACKFILE* f, word s_version, combo_trigger& temp_trigger)
18168 {
18169 byte tempbyte;
18170
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 8863 times.
15975 if(s_version >= 52)
18171
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_getcstr(&temp_trigger.label,f))
18172 return qe_invalid;
18173
18174
2/2
✓ Branch 0 taken 7358 times.
✓ Branch 1 taken 8617 times.
15975 if(s_version < 57)
18175 {
18176 7358 int32_t temp_trigflags[6] = {0};
18177 7358 int numtrigs = s_version < 36 ? 3 : 6;
18178
2/2
✓ Branch 0 taken 43290 times.
✓ Branch 1 taken 7358 times.
50648 for ( int32_t q = 0; q < numtrigs; q++ )
18179
1/2
✓ Branch 0 taken 43290 times.
✗ Branch 1 not taken.
43290 if(!p_igetl(&temp_trigflags[q],f))
18180 return qe_invalid;
18181 7358 temp_trigger.trigger_flags.clear();
18182
2/2
✓ Branch 0 taken 1385280 times.
✓ Branch 1 taken 7358 times.
1392638 for(size_t q = 0; q < 32*numtrigs; ++q)
18183 {
18184 1385280 auto ind = q/32;
18185 1385280 auto bit = 1<<(q%32);
18186
2/2
✓ Branch 0 taken 1372321 times.
✓ Branch 1 taken 12959 times.
1385280 if(temp_trigflags[ind] & bit)
18187 12959 temp_trigger.trigger_flags.set(q, true);
18188 1385280 }
18189 7358 }
18190
1/2
✓ Branch 0 taken 8617 times.
✗ Branch 1 not taken.
8617 else if(!p_getbitstr(&temp_trigger.trigger_flags,f))
18191 return qe_invalid;
18192
1/2
✓ Branch 0 taken 15975 times.
✗ Branch 1 not taken.
15975 if(!p_igetl(&temp_trigger.triggerlevel,f))
18193 return qe_invalid;
18194
1/2
✓ Branch 0 taken 15975 times.
✗ Branch 1 not taken.
15975 if(!p_getc(&temp_trigger.triggerbtn,f))
18195 return qe_invalid;
18196
1/2
✓ Branch 0 taken 15975 times.
✗ Branch 1 not taken.
15975 if(!p_getc(&temp_trigger.triggeritem,f))
18197 return qe_invalid;
18198
2/2
✓ Branch 0 taken 8863 times.
✓ Branch 1 taken 7112 times.
15975 if(s_version >= 53)
18199 {
18200
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_igetw(&temp_trigger.trigtimer,f))
18201 return qe_invalid;
18202 8863 }
18203 else
18204 {
18205
1/2
✓ Branch 0 taken 7112 times.
✗ Branch 1 not taken.
7112 if(!p_getc(&tempbyte, f))
18206 return qe_invalid;
18207 7112 temp_trigger.trigtimer = tempbyte;
18208 }
18209
1/2
✓ Branch 0 taken 15975 times.
✗ Branch 1 not taken.
15975 if(!p_getc(&temp_trigger.trigsfx,f))
18210 return qe_invalid;
18211
1/2
✓ Branch 0 taken 15975 times.
✗ Branch 1 not taken.
15975 if(!p_igetl(&temp_trigger.trigchange,f))
18212 return qe_invalid;
18213
1/2
✓ Branch 0 taken 15975 times.
✗ Branch 1 not taken.
15975 if(!p_igetw(&temp_trigger.trigprox,f))
18214 return qe_invalid;
18215
2/2
✓ Branch 0 taken 8863 times.
✓ Branch 1 taken 7112 times.
15975 if(s_version >= 53)
18216 {
18217
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_igetw(&temp_trigger.trigctr,f))
18218 return qe_invalid;
18219 8863 }
18220 else
18221 {
18222
1/2
✓ Branch 0 taken 7112 times.
✗ Branch 1 not taken.
7112 if(!p_getc(&tempbyte,f))
18223 return qe_invalid;
18224 7112 temp_trigger.trigctr = tempbyte;
18225 }
18226
1/2
✓ Branch 0 taken 15975 times.
✗ Branch 1 not taken.
15975 if(!p_igetl(&temp_trigger.trigctramnt,f))
18227 return qe_invalid;
18228
1/2
✓ Branch 0 taken 15975 times.
✗ Branch 1 not taken.
15975 if(!p_getc(&temp_trigger.triglbeam,f))
18229 return qe_invalid;
18230
1/2
✓ Branch 0 taken 15975 times.
✗ Branch 1 not taken.
15975 if(!p_getc(&temp_trigger.trigcschange,f))
18231 return qe_invalid;
18232
1/2
✓ Branch 0 taken 15975 times.
✗ Branch 1 not taken.
15975 if(!p_igetw(&temp_trigger.spawnitem,f))
18233 return qe_invalid;
18234
1/2
✓ Branch 0 taken 15975 times.
✗ Branch 1 not taken.
15975 if(!p_igetw(&temp_trigger.spawnenemy,f))
18235 return qe_invalid;
18236
1/2
✓ Branch 0 taken 15975 times.
✗ Branch 1 not taken.
15975 if(!p_getc(&temp_trigger.exstate,f))
18237 return qe_invalid;
18238
1/2
✓ Branch 0 taken 15975 times.
✗ Branch 1 not taken.
15975 if(!p_igetl(&temp_trigger.spawnip,f))
18239 return qe_invalid;
18240
1/2
✓ Branch 0 taken 15975 times.
✗ Branch 1 not taken.
15975 if(!p_getc(&temp_trigger.trigcopycat,f))
18241 return qe_invalid;
18242
1/2
✓ Branch 0 taken 15975 times.
✗ Branch 1 not taken.
15975 if(!p_getc(&temp_trigger.trigcooldown,f))
18243 return qe_invalid;
18244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15975 times.
15975 if(s_version >= 35)
18245 {
18246
1/2
✓ Branch 0 taken 15975 times.
✗ Branch 1 not taken.
15975 if(!p_igetw(&temp_trigger.prompt_cid,f))
18247 return qe_invalid;
18248
1/2
✓ Branch 0 taken 15975 times.
✗ Branch 1 not taken.
15975 if(!p_getc(&temp_trigger.prompt_cs,f))
18249 return qe_invalid;
18250
1/2
✓ Branch 0 taken 15975 times.
✗ Branch 1 not taken.
15975 if(!p_igetw(&temp_trigger.prompt_x,f))
18251 return qe_invalid;
18252
1/2
✓ Branch 0 taken 15975 times.
✗ Branch 1 not taken.
15975 if(!p_igetw(&temp_trigger.prompt_y,f))
18253 return qe_invalid;
18254 15975 }
18255
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 15689 times.
15975 if(s_version >= 36)
18256 {
18257
1/2
✓ Branch 0 taken 15689 times.
✗ Branch 1 not taken.
15689 if(!p_getc(&temp_trigger.trig_lstate,f))
18258 return qe_invalid;
18259
1/2
✓ Branch 0 taken 15689 times.
✗ Branch 1 not taken.
15689 if(!p_getc(&temp_trigger.trig_gstate,f))
18260 return qe_invalid;
18261
1/2
✓ Branch 0 taken 15689 times.
✗ Branch 1 not taken.
15689 if(!p_igetl(&temp_trigger.trig_statetime,f))
18262 return qe_invalid;
18263 15689 }
18264
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 15689 times.
15975 if(s_version >= 37)
18265 {
18266
1/2
✓ Branch 0 taken 15689 times.
✗ Branch 1 not taken.
15689 if(!p_igetw(&temp_trigger.trig_genscr,f))
18267 return qe_invalid;
18268 15689 }
18269
2/2
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 15541 times.
15975 if(s_version >= 38)
18270 {
18271
1/2
✓ Branch 0 taken 15541 times.
✗ Branch 1 not taken.
15541 if(!p_getc(&temp_trigger.trig_group,f))
18272 return qe_invalid;
18273
1/2
✓ Branch 0 taken 15541 times.
✗ Branch 1 not taken.
15541 if(!p_igetw(&temp_trigger.trig_group_val,f))
18274 return qe_invalid;
18275 15541 }
18276
2/2
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 15505 times.
15975 if(s_version >= 45)
18277 {
18278
1/2
✓ Branch 0 taken 15505 times.
✗ Branch 1 not taken.
15505 if(!p_getc(&temp_trigger.exdoor_dir,f))
18279 return qe_invalid;
18280
1/2
✓ Branch 0 taken 15505 times.
✗ Branch 1 not taken.
15505 if(!p_getc(&temp_trigger.exdoor_ind,f))
18281 return qe_invalid;
18282 15505 }
18283
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 8863 times.
15975 if(s_version >= 46)
18284 {
18285
2/2
✓ Branch 0 taken 5273 times.
✓ Branch 1 taken 3590 times.
8863 if (s_version >= 59)
18286 {
18287
1/2
✓ Branch 0 taken 5273 times.
✗ Branch 1 not taken.
5273 if(!p_igetw(&temp_trigger.trig_levelitems,f))
18288 return qe_invalid;
18289 5273 }
18290 else
18291 {
18292
1/2
✓ Branch 0 taken 3590 times.
✗ Branch 1 not taken.
3590 if(!p_getc(&tempbyte,f))
18293 return qe_invalid;
18294 3590 temp_trigger.trig_levelitems = word(tempbyte);
18295 }
18296
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_igetw(&temp_trigger.trigdmlevel,f))
18297 return qe_invalid;
18298
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(s_version >= 48)
18299 {
18300
2/2
✓ Branch 0 taken 26589 times.
✓ Branch 1 taken 8863 times.
35452 for(int q = 0; q < 3; ++q)
18301
1/2
✓ Branch 0 taken 26589 times.
✗ Branch 1 not taken.
26589 if(!p_igetw(&temp_trigger.trigtint[q],f))
18302 return qe_invalid;
18303 8863 }
18304 else
18305 {
18306 for(int q = 0; q < 3; ++q)
18307 if(!p_getc(&temp_trigger.trigtint[q],f))
18308 return qe_invalid;
18309 for(int q = 0; q < 3; ++q)
18310 {
18311 int v = temp_trigger.trigtint[q];
18312 int va = abs(v);
18313 temp_trigger.trigtint[q] = _rgb_scale_6[va] * sign(v);
18314 }
18315 }
18316
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_igetw(&temp_trigger.triglvlpalette,f))
18317 return qe_invalid;
18318
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_igetw(&temp_trigger.trigbosspalette,f))
18319 return qe_invalid;
18320
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_igetw(&temp_trigger.trigquaketime,f))
18321 return qe_invalid;
18322
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_igetw(&temp_trigger.trigwavytime,f))
18323 return qe_invalid;
18324
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_igetw(&temp_trigger.trig_swjinxtime,f))
18325 return qe_invalid;
18326
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_igetw(&temp_trigger.trig_itmjinxtime,f))
18327 return qe_invalid;
18328
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_igetw(&temp_trigger.trig_stuntime,f))
18329 return qe_invalid;
18330
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_igetw(&temp_trigger.trig_bunnytime,f))
18331 return qe_invalid;
18332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8863 times.
8863 if(!p_getc(&temp_trigger.trig_pushtime,f))
18333 return qe_invalid;
18334 8863 }
18335
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 8863 times.
15975 if(s_version >= 47)
18336 {
18337
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if (!p_igetw(&temp_trigger.trig_shieldjinxtime, f))
18338 return qe_invalid;
18339 8863 }
18340
2/2
✓ Branch 0 taken 8863 times.
✓ Branch 1 taken 7112 times.
15975 if(s_version >= 53)
18341 {
18342
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_igetl(&temp_trigger.req_level_state, f))
18343 return qe_invalid;
18344
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_igetl(&temp_trigger.unreq_level_state, f))
18345 return qe_invalid;
18346
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_getbitstr(&temp_trigger.req_global_state, f))
18347 return qe_invalid;
18348
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_getbitstr(&temp_trigger.unreq_global_state, f))
18349 return qe_invalid;
18350
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_igetw(&temp_trigger.fail_prompt_cid,f))
18351 return qe_invalid;
18352
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_getc(&temp_trigger.fail_prompt_cs,f))
18353 return qe_invalid;
18354
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_igetl(&temp_trigger.trig_msgstr, f))
18355 return qe_invalid;
18356
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_igetl(&temp_trigger.fail_msgstr, f))
18357 return qe_invalid;
18358
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_igetzf(&temp_trigger.player_bounce, f))
18359 return qe_invalid;
18360
1/2
✓ Branch 0 taken 8863 times.
✗ Branch 1 not taken.
8863 if(!p_igetzf(&temp_trigger.req_player_z, f))
18361 return qe_invalid;
18362 8863 }
18363 else
18364 {
18365 7112 temp_trigger.fail_prompt_cid = temp_trigger.prompt_cid;
18366 7112 temp_trigger.fail_prompt_cs = temp_trigger.prompt_cs;
18367 }
18368
2/2
✓ Branch 0 taken 7358 times.
✓ Branch 1 taken 8617 times.
15975 if(s_version >= 54)
18369 {
18370
1/2
✓ Branch 0 taken 8617 times.
✗ Branch 1 not taken.
8617 if(!p_getc(&temp_trigger.req_player_dir,f))
18371 return qe_invalid;
18372
1/2
✓ Branch 0 taken 8617 times.
✗ Branch 1 not taken.
8617 if(!p_igetzf(&temp_trigger.dest_player_x, f))
18373 return qe_invalid;
18374
1/2
✓ Branch 0 taken 8617 times.
✗ Branch 1 not taken.
8617 if(!p_igetzf(&temp_trigger.dest_player_y, f))
18375 return qe_invalid;
18376
1/2
✓ Branch 0 taken 8617 times.
✗ Branch 1 not taken.
8617 if(!p_igetzf(&temp_trigger.dest_player_z, f))
18377 return qe_invalid;
18378
1/2
✓ Branch 0 taken 8617 times.
✗ Branch 1 not taken.
8617 if(!p_igetzf(&temp_trigger.req_player_jump, f))
18379 return qe_invalid;
18380
1/2
✓ Branch 0 taken 8617 times.
✗ Branch 1 not taken.
8617 if(!p_igetzf(&temp_trigger.req_player_x, f))
18381 return qe_invalid;
18382
1/2
✓ Branch 0 taken 8617 times.
✗ Branch 1 not taken.
8617 if(!p_igetzf(&temp_trigger.req_player_y, f))
18383 return qe_invalid;
18384 8617 }
18385
2/2
✓ Branch 0 taken 7358 times.
✓ Branch 1 taken 8617 times.
15975 if(s_version >= 56)
18386 {
18387
1/2
✓ Branch 0 taken 8617 times.
✗ Branch 1 not taken.
8617 if(!p_getc(&temp_trigger.dest_player_dir, f))
18388 return qe_invalid;
18389
1/2
✓ Branch 0 taken 8617 times.
✗ Branch 1 not taken.
8617 if(!p_igetl(&temp_trigger.force_ice_combo, f))
18390 return qe_invalid;
18391
1/2
✓ Branch 0 taken 8617 times.
✗ Branch 1 not taken.
8617 if(!p_igetzf(&temp_trigger.force_ice_vx, f))
18392 return qe_invalid;
18393
1/2
✓ Branch 0 taken 8617 times.
✗ Branch 1 not taken.
8617 if(!p_igetzf(&temp_trigger.force_ice_vy, f))
18394 return qe_invalid;
18395 8617 }
18396
2/2
✓ Branch 0 taken 10702 times.
✓ Branch 1 taken 5273 times.
15975 if(s_version >= 58)
18397 {
18398
1/2
✓ Branch 0 taken 5273 times.
✗ Branch 1 not taken.
5273 if(!p_igetzf(&temp_trigger.trig_gravity, f))
18399 return qe_invalid;
18400
1/2
✓ Branch 0 taken 5273 times.
✗ Branch 1 not taken.
5273 if(!p_igetzf(&temp_trigger.trig_terminal_v, f))
18401 return qe_invalid;
18402 5273 }
18403 15975 return 0;
18404 15975 }
18405
18406 1657153 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18407 {
18408 byte tempbyte;
18409 word combo_has_flags;
18410
2/2
✓ Branch 0 taken 513191 times.
✓ Branch 1 taken 1143962 times.
1657153 if(s_version < 55)
18411 {
18412
1/2
✓ Branch 0 taken 513191 times.
✗ Branch 1 not taken.
513191 if(!p_getc(&tempbyte,f))
18413 return qe_invalid;
18414 513191 combo_has_flags = tempbyte;
18415 513191 }
18416 else
18417 {
18418
1/2
✓ Branch 0 taken 1143962 times.
✗ Branch 1 not taken.
1143962 if(!p_igetw(&combo_has_flags,f))
18419 return qe_invalid;
18420 }
18421
18422 1657153 temp_combo.clear();
18423
2/2
✓ Branch 0 taken 290882 times.
✓ Branch 1 taken 1366271 times.
1657153 if(combo_has_flags)
18424 {
18425
2/2
✓ Branch 0 taken 587686 times.
✓ Branch 1 taken 778585 times.
1366271 if(combo_has_flags&CHAS_BASIC)
18426 {
18427
1/2
✓ Branch 0 taken 778585 times.
✗ Branch 1 not taken.
778585 if(!p_igetl(&temp_combo.tile,f))
18428 return qe_invalid;
18429 778585 temp_combo.o_tile = temp_combo.tile;
18430
18431
1/2
✓ Branch 0 taken 778585 times.
✗ Branch 1 not taken.
778585 if(!p_getc(&temp_combo.flip,f))
18432 return qe_invalid;
18433
18434
1/2
✓ Branch 0 taken 778585 times.
✗ Branch 1 not taken.
778585 if(!p_getc(&temp_combo.walk,f))
18435 return qe_invalid;
18436
18437
1/2
✓ Branch 0 taken 778585 times.
✗ Branch 1 not taken.
778585 if(!p_getc(&temp_combo.type,f))
18438 return qe_invalid;
18439
18440
1/2
✓ Branch 0 taken 778585 times.
✗ Branch 1 not taken.
778585 if(!p_getc(&temp_combo.flag,f))
18441 return qe_invalid;
18442
18443
1/2
✓ Branch 0 taken 778585 times.
✗ Branch 1 not taken.
778585 if(!p_getc(&temp_combo.csets,f))
18444 return qe_invalid;
18445 778585 }
18446
2/2
✓ Branch 0 taken 1362884 times.
✓ Branch 1 taken 3387 times.
1366271 if(combo_has_flags&CHAS_SCRIPT)
18447 {
18448
2/2
✓ Branch 0 taken 3357 times.
✓ Branch 1 taken 30 times.
3387 if (s_version>=41)
18449 {
18450 3357 p_getcstr(&temp_combo.label, f);
18451 3357 }
18452 else
18453 {
18454 char label[12];
18455 30 label[11] = '\0';
18456
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 30 times.
360 for ( int32_t q = 0; q < 11; q++ )
18457
1/2
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
330 if(!p_getc(&label[q],f))
18458 return qe_invalid;
18459 30 temp_combo.label = label;
18460 }
18461
18462
1/2
✓ Branch 0 taken 3387 times.
✗ Branch 1 not taken.
3387 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
18463 3387 auto initd_count = s_version >= 43 ? 8 : 2;
18464
2/2
✓ Branch 0 taken 26916 times.
✓ Branch 1 taken 3387 times.
30303 for ( int32_t q = 0; q < initd_count; q++ )
18465
1/2
✓ Branch 0 taken 26916 times.
✗ Branch 1 not taken.
26916 if(!p_igetl(&temp_combo.initd[q],f))
18466 return qe_invalid;
18467 3387 }
18468
2/2
✓ Branch 0 taken 1182860 times.
✓ Branch 1 taken 183411 times.
1366271 if(combo_has_flags&CHAS_ANIM)
18469 {
18470
1/2
✓ Branch 0 taken 183411 times.
✗ Branch 1 not taken.
183411 if(!p_getc(&temp_combo.frames,f))
18471 return qe_invalid;
18472
18473
1/2
✓ Branch 0 taken 183411 times.
✗ Branch 1 not taken.
183411 if(!p_getc(&temp_combo.speed,f))
18474 return qe_invalid;
18475
18476
1/2
✓ Branch 0 taken 183411 times.
✗ Branch 1 not taken.
183411 if(!p_igetw(&temp_combo.nextcombo,f))
18477 return qe_invalid;
18478
18479
1/2
✓ Branch 0 taken 183411 times.
✗ Branch 1 not taken.
183411 if(!p_getc(&temp_combo.nextcset,f))
18480 return qe_invalid;
18481
18482
1/2
✓ Branch 0 taken 183411 times.
✗ Branch 1 not taken.
183411 if(!p_getc(&temp_combo.skipanim,f))
18483 return qe_invalid;
18484
18485
1/2
✓ Branch 0 taken 183411 times.
✗ Branch 1 not taken.
183411 if(!p_getc(&temp_combo.skipanimy,f))
18486 return qe_invalid;
18487
18488
1/2
✓ Branch 0 taken 183411 times.
✗ Branch 1 not taken.
183411 if(!p_getc(&temp_combo.animflags,f))
18489 return qe_invalid;
18490 183411 }
18491
2/2
✓ Branch 0 taken 1302712 times.
✓ Branch 1 taken 63559 times.
1366271 if(combo_has_flags&CHAS_ATTRIB)
18492 {
18493
2/2
✓ Branch 0 taken 254236 times.
✓ Branch 1 taken 63559 times.
317795 for ( int32_t q = 0; q < 4; q++ )
18494
1/2
✓ Branch 0 taken 254236 times.
✗ Branch 1 not taken.
254236 if(!p_igetl(&temp_combo.attributes[q],f))
18495 return qe_invalid;
18496
2/2
✓ Branch 0 taken 508472 times.
✓ Branch 1 taken 63559 times.
572031 for ( int32_t q = 0; q < 8; q++ )
18497
1/2
✓ Branch 0 taken 508472 times.
✗ Branch 1 not taken.
508472 if(!p_getc(&temp_combo.attribytes[q],f))
18498 return qe_invalid;
18499
2/2
✓ Branch 0 taken 508472 times.
✓ Branch 1 taken 63559 times.
572031 for ( int32_t q = 0; q < 8; q++ )
18500
1/2
✓ Branch 0 taken 508472 times.
✗ Branch 1 not taken.
508472 if(!p_igetw(&temp_combo.attrishorts[q],f))
18501 return qe_invalid;
18502 63559 }
18503
2/2
✓ Branch 0 taken 1350482 times.
✓ Branch 1 taken 15789 times.
1366271 if(combo_has_flags&CHAS_FLAG)
18504 {
18505
1/2
✓ Branch 0 taken 15789 times.
✗ Branch 1 not taken.
15789 if(!p_igetl(&temp_combo.usrflags,f))
18506 return qe_invalid;
18507
1/2
✓ Branch 0 taken 15789 times.
✗ Branch 1 not taken.
15789 if(!p_igetw(&temp_combo.genflags,f))
18508 return qe_invalid;
18509 15789 }
18510
2/2
✓ Branch 0 taken 1350373 times.
✓ Branch 1 taken 15898 times.
1366271 if(combo_has_flags&CHAS_TRIG)
18511 {
18512 15898 byte count = 1;
18513
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 8786 times.
15898 if(s_version >= 52)
18514
1/2
✓ Branch 0 taken 8786 times.
✗ Branch 1 not taken.
8786 if(!p_getc(&count, f))
18515 return qe_invalid;
18516
18517
2/2
✓ Branch 0 taken 15975 times.
✓ Branch 1 taken 15898 times.
31873 for(byte q = 0; q < count; ++q)
18518 {
18519 15975 combo_trigger& temp_trigger = temp_combo.triggers.emplace_back();
18520 15975 auto ret = readcombo_triggers_loop(f, s_version, temp_trigger);
18521
1/2
✓ Branch 0 taken 15975 times.
✗ Branch 1 not taken.
15975 if(ret)
18522 return ret;
18523 15975 }
18524
18525
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 8786 times.
15898 if(s_version < 52)
18526 {
18527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7112 times.
7112 if(!temp_combo.triggers.empty())
18528 7112 temp_combo.only_gentrig = (temp_combo.triggers[0].trigger_flags.get(TRIGFLAG_ONLYGENTRIG)) ? 1 : 0;
18529 7112 }
18530
1/2
✓ Branch 0 taken 8786 times.
✗ Branch 1 not taken.
8786 else if(!p_getc(&temp_combo.only_gentrig,f))
18531 return qe_invalid;
18532 15898 }
18533
2/2
✓ Branch 0 taken 222186 times.
✓ Branch 1 taken 1144085 times.
1366271 if(combo_has_flags&CHAS_LIFT)
18534 {
18535
1/2
✓ Branch 0 taken 1144085 times.
✗ Branch 1 not taken.
1144085 if(!p_igetw(&temp_combo.liftcmb,f))
18536 return qe_invalid;
18537
1/2
✓ Branch 0 taken 1144085 times.
✗ Branch 1 not taken.
1144085 if(!p_getc(&temp_combo.liftcs,f))
18538 return qe_invalid;
18539
1/2
✓ Branch 0 taken 1144085 times.
✗ Branch 1 not taken.
1144085 if(!p_igetw(&temp_combo.liftundercmb,f))
18540 return qe_invalid;
18541
1/2
✓ Branch 0 taken 1144085 times.
✗ Branch 1 not taken.
1144085 if(!p_getc(&temp_combo.liftundercs,f))
18542 return qe_invalid;
18543
1/2
✓ Branch 0 taken 1144085 times.
✗ Branch 1 not taken.
1144085 if(!p_getc(&temp_combo.liftdmg,f))
18544 return qe_invalid;
18545
1/2
✓ Branch 0 taken 1144085 times.
✗ Branch 1 not taken.
1144085 if(!p_getc(&temp_combo.liftlvl,f))
18546 return qe_invalid;
18547
1/2
✓ Branch 0 taken 1144085 times.
✗ Branch 1 not taken.
1144085 if(!p_getc(&temp_combo.liftitm,f))
18548 return qe_invalid;
18549
1/2
✓ Branch 0 taken 1144085 times.
✗ Branch 1 not taken.
1144085 if(!p_getc(&temp_combo.liftflags,f))
18550 return qe_invalid;
18551
1/2
✓ Branch 0 taken 1144085 times.
✗ Branch 1 not taken.
1144085 if(!p_getc(&temp_combo.liftgfx,f))
18552 return qe_invalid;
18553
1/2
✓ Branch 0 taken 1144085 times.
✗ Branch 1 not taken.
1144085 if(!p_getc(&temp_combo.liftsprite,f))
18554 return qe_invalid;
18555
1/2
✓ Branch 0 taken 1144085 times.
✗ Branch 1 not taken.
1144085 if(!p_getc(&temp_combo.liftsfx,f))
18556 return qe_invalid;
18557
1/2
✓ Branch 0 taken 1144085 times.
✗ Branch 1 not taken.
1144085 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18558 return qe_invalid;
18559
1/2
✓ Branch 0 taken 1144085 times.
✗ Branch 1 not taken.
1144085 if(!p_getc(&temp_combo.liftbreaksfx,f))
18560 return qe_invalid;
18561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1144085 times.
1144085 if(s_version >= 34)
18562 {
18563
1/2
✓ Branch 0 taken 1144085 times.
✗ Branch 1 not taken.
1144085 if(!p_getc(&temp_combo.lifthei,f))
18564 return qe_invalid;
18565
1/2
✓ Branch 0 taken 1144085 times.
✗ Branch 1 not taken.
1144085 if(!p_getc(&temp_combo.lifttime,f))
18566 return qe_invalid;
18567 1144085 }
18568
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1144071 times.
1144085 if(s_version >= 39)
18569 {
18570
1/2
✓ Branch 0 taken 1144071 times.
✗ Branch 1 not taken.
1144071 if(!p_getc(&temp_combo.lift_parent_item,f))
18571 return qe_invalid;
18572 1144071 }
18573 1144085 auto& weap_data = temp_combo.lift_weap_data;
18574
4/4
✓ Branch 0 taken 1143986 times.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 1143962 times.
✓ Branch 3 taken 24 times.
1144085 if(s_version >= 51 && s_version < 55)
18575 {
18576
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&weap_data.light_rads[WPNSPR_BASE],f))
18577 return qe_invalid;
18578
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&weap_data.glow_shape,f))
18579 return qe_invalid;
18580 24 }
18581
18582
2/2
✓ Branch 0 taken 1143962 times.
✓ Branch 1 taken 123 times.
1144085 if(s_version >= 55)
18583 {
18584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1143962 times.
1143962 if(auto ret = read_weap_data(weap_data, f))
18585 return ret;
18586 1143962 }
18587 else
18588 {
18589 123 auto const& pitm = itemsbuf[temp_combo.lift_parent_item];
18590 123 auto weap_glow = weap_data.light_rads[WPNSPR_BASE];
18591
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 117 times.
123 switch(pitm.type)
18592 {
18593 case itype_bomb:
18594 case itype_sbomb:
18595 6 weap_data = pitm.weap_data;
18596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(!(weap_data.wflags & WFLAG_UPDATE_IGNITE_SPRITE))
18597 {
18598 6 weap_data.flags |= wdata_glow_rad;
18599 6 weap_data.light_rads[WPNSPR_BASE] = weap_glow;
18600 6 }
18601 6 break;
18602 default:
18603 117 weap_data.wflags |= WFLAG_BREAK_WHEN_LANDING;
18604 117 weap_data.flags |= wdata_glow_rad;
18605 117 }
18606 123 weap_data.moveflags |= move_obeys_grav|move_can_pitfall;
18607
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 63 times.
123 if(temp_combo.liftflags & LF_BREAKONSOLID)
18608 60 weap_data.wflags |= WFLAG_BREAK_ON_SOLID;
18609 }
18610 1144085 }
18611
18612
2/2
✓ Branch 0 taken 1331163 times.
✓ Branch 1 taken 35108 times.
1366271 if(combo_has_flags&CHAS_GENERAL)
18613 {
18614
1/2
✓ Branch 0 taken 35108 times.
✗ Branch 1 not taken.
35108 if(!p_getc(&temp_combo.speed_mult,f))
18615 return qe_invalid;
18616
1/2
✓ Branch 0 taken 35108 times.
✗ Branch 1 not taken.
35108 if(!p_getc(&temp_combo.speed_div,f))
18617 return qe_invalid;
18618
1/2
✓ Branch 0 taken 35108 times.
✗ Branch 1 not taken.
35108 if(!p_igetzf(&temp_combo.speed_add,f))
18619 return qe_invalid;
18620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35108 times.
35108 if(s_version >= 42)
18621 {
18622
1/2
✓ Branch 0 taken 35108 times.
✗ Branch 1 not taken.
35108 if(!p_getc(&temp_combo.sfx_appear,f))
18623 return qe_invalid;
18624
1/2
✓ Branch 0 taken 35108 times.
✗ Branch 1 not taken.
35108 if(!p_getc(&temp_combo.sfx_disappear,f))
18625 return qe_invalid;
18626
1/2
✓ Branch 0 taken 35108 times.
✗ Branch 1 not taken.
35108 if(!p_getc(&temp_combo.sfx_loop,f))
18627 return qe_invalid;
18628
1/2
✓ Branch 0 taken 35108 times.
✗ Branch 1 not taken.
35108 if(!p_getc(&temp_combo.sfx_walking,f))
18629 return qe_invalid;
18630
1/2
✓ Branch 0 taken 35108 times.
✗ Branch 1 not taken.
35108 if(!p_getc(&temp_combo.sfx_standing,f))
18631 return qe_invalid;
18632
1/2
✓ Branch 0 taken 35108 times.
✗ Branch 1 not taken.
35108 if(!p_getc(&temp_combo.spr_appear,f))
18633 return qe_invalid;
18634
1/2
✓ Branch 0 taken 35108 times.
✗ Branch 1 not taken.
35108 if(!p_getc(&temp_combo.spr_disappear,f))
18635 return qe_invalid;
18636
1/2
✓ Branch 0 taken 35108 times.
✗ Branch 1 not taken.
35108 if(!p_getc(&temp_combo.spr_walking,f))
18637 return qe_invalid;
18638
1/2
✓ Branch 0 taken 35108 times.
✗ Branch 1 not taken.
35108 if(!p_getc(&temp_combo.spr_standing,f))
18639 return qe_invalid;
18640 35108 }
18641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35108 times.
35108 if(s_version >= 44)
18642 {
18643
1/2
✓ Branch 0 taken 35108 times.
✗ Branch 1 not taken.
35108 if(!p_getc(&temp_combo.sfx_tap,f))
18644 return qe_invalid;
18645 35108 }
18646
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 34742 times.
35108 if(s_version >= 49)
18647 {
18648
1/2
✓ Branch 0 taken 34742 times.
✗ Branch 1 not taken.
34742 if(!p_getc(&temp_combo.sfx_landing,f))
18649 return qe_invalid;
18650 34742 }
18651
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 34742 times.
35108 if(s_version >= 50)
18652 {
18653
1/2
✓ Branch 0 taken 34742 times.
✗ Branch 1 not taken.
34742 if(!p_getc(&temp_combo.spr_falling,f))
18654 return qe_invalid;
18655
1/2
✓ Branch 0 taken 34742 times.
✗ Branch 1 not taken.
34742 if(!p_getc(&temp_combo.spr_drowning,f))
18656 return qe_invalid;
18657
1/2
✓ Branch 0 taken 34742 times.
✗ Branch 1 not taken.
34742 if(!p_getc(&temp_combo.spr_lava_drowning,f))
18658 return qe_invalid;
18659
1/2
✓ Branch 0 taken 34742 times.
✗ Branch 1 not taken.
34742 if(!p_getc(&temp_combo.sfx_falling,f))
18660 return qe_invalid;
18661
1/2
✓ Branch 0 taken 34742 times.
✗ Branch 1 not taken.
34742 if(!p_getc(&temp_combo.sfx_drowning,f))
18662 return qe_invalid;
18663
1/2
✓ Branch 0 taken 34742 times.
✗ Branch 1 not taken.
34742 if(!p_getc(&temp_combo.sfx_lava_drowning,f))
18664 return qe_invalid;
18665 34742 }
18666
2/2
✓ Branch 0 taken 1860 times.
✓ Branch 1 taken 33248 times.
35108 if(s_version >= 56)
18667 {
18668
1/2
✓ Branch 0 taken 33248 times.
✗ Branch 1 not taken.
33248 if(!p_igetzf(&temp_combo.z_height,f))
18669 return qe_invalid;
18670
1/2
✓ Branch 0 taken 33248 times.
✗ Branch 1 not taken.
33248 if(!p_igetzf(&temp_combo.z_step_height,f))
18671 return qe_invalid;
18672 33248 }
18673
2/2
✓ Branch 0 taken 3283 times.
✓ Branch 1 taken 31825 times.
35108 if(s_version >= 60)
18674 {
18675
1/2
✓ Branch 0 taken 31825 times.
✗ Branch 1 not taken.
31825 if(!p_getc(&temp_combo.dive_under_level,f))
18676 return qe_invalid;
18677 31825 }
18678 35108 }
18679
1/2
✓ Branch 0 taken 1366271 times.
✗ Branch 1 not taken.
1366271 if(combo_has_flags&CHAS_MISC_WEAP_DATA)
18680 {
18681 if(auto ret = read_weap_data(temp_combo.misc_weap_data, f))
18682 return ret;
18683 }
18684 1366271 }
18685 1657153 update_combo(temp_combo, s_version);
18686 1657153 return 0;
18687 1657153 }
18688
18689 491 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18690 {
18691
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 24 times.
491 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
18692
18693 491 word section_version=0;
18694 491 word combos_used=0;
18695 int32_t dummy;
18696 byte padding;
18697 491 newcombo temp_combo;
18698
18699
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 490 times.
491 if (!should_skip)
18700 {
18701
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 reset_all_combo_animations();
18702
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 init_combo_classes();
18703
18704
2/2
✓ Branch 0 taken 31987200 times.
✓ Branch 1 taken 490 times.
31987690 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18705
1/2
✓ Branch 0 taken 31987200 times.
✗ Branch 1 not taken.
31987200 combobuf[q].clear();
18706 490 }
18707
18708
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 24 times.
491 if(version > 0x192) //Version info
18709 {
18710
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
467 if(!p_igetw(&section_version,f))
18711 {
18712 return qe_invalid;
18713 }
18714 467 FFCore.quest_format[vCombos] = section_version;
18715
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
467 if(!read_deprecated_section_cversion(f))
18716 {
18717 return qe_invalid;
18718 }
18719
18720 //section size
18721
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
467 if(!p_igetl(&dummy,f))
18722 {
18723 return qe_invalid;
18724 }
18725 467 }
18726
18727
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 288 times.
491 if(section_version > 32) //Cleanup time!
18728 {
18729
2/4
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
203 if(!p_igetw(&combos_used,f))
18730 {
18731 return qe_invalid;
18732 }
18733
2/2
✓ Branch 0 taken 1657153 times.
✓ Branch 1 taken 203 times.
1657356 for(int32_t i=0; i<combos_used; i++)
18734 {
18735
1/2
✓ Branch 0 taken 1657153 times.
✗ Branch 1 not taken.
1657153 auto ret = readcombo_loop(f,section_version,temp_combo);
18736
1/2
✓ Branch 0 taken 1657153 times.
✗ Branch 1 not taken.
1657153 if(ret) return ret;
18737
1/2
✓ Branch 0 taken 1657153 times.
✗ Branch 1 not taken.
1657153 if(i>=start_combo)
18738 {
18739
1/2
✓ Branch 0 taken 1657153 times.
✗ Branch 1 not taken.
1657153 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18740 {
18741 temp_combo.script = 0;
18742 for(int q = 0; q < 8; ++q)
18743 temp_combo.initd[q] = 0;
18744 }
18745
1/2
✓ Branch 0 taken 1657153 times.
✗ Branch 1 not taken.
1657153 combobuf[i] = temp_combo;
18746 1657153 }
18747 1657153 }
18748 203 }
18749 else //Call the old function for all old versions
18750 {
18751
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if(ret) return ret; //error, end read
18753 }
18754
18755
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 1 times.
491 if (should_skip)
18756 1 return 0;
18757
18758
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 194 times.
490 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18759 {
18760 194 combobuf[0].walk = 0xF0;
18761 194 combobuf[0].type = 0;
18762 194 combobuf[0].flag = 0;
18763 194 }
18764
18765
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 setup_combo_animations();
18766
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 setup_combo_animations2();
18767 490 return 0;
18768 491 }
18769
18770 408 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18771 {
18772 //these are here to bypass compiler warnings about unused arguments
18773 408 Header=Header;
18774 408 version=version;
18775 408 build=build;
18776
18777 int32_t dummy;
18778 408 word sversion=0, c_sversion;
18779
18780 //section version info
18781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(!p_igetw(&sversion,f))
18782 {
18783 return qe_invalid;
18784 }
18785
18786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if (sversion > V_COMBOALIASES)
18787 return qe_version;
18788
18789 408 FFCore.quest_format[vComboAliases] = sversion;
18790
18791
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_igetw(&c_sversion,f))
18792 {
18793 return qe_invalid;
18794 }
18795
18796 //section size
18797
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_igetl(&dummy,f))
18798 {
18799 return qe_invalid;
18800 }
18801
18802 408 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18803
18804
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 200 times.
408 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18805 {
18806 200 max_num_combo_aliases = MAX250COMBOALIASES;
18807 200 }
18808
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18809 {
18810 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18811 }
18812
18813
2/2
✓ Branch 0 taken 2113536 times.
✓ Branch 1 taken 408 times.
2113944 for(int32_t j=0; j<max_num_combo_aliases; j++)
18814 {
18815 byte width,height,mask,tempcset;
18816 int32_t count;
18817 word tempword;
18818 byte tempbyte;
18819
18820
1/2
✓ Branch 0 taken 2113536 times.
✗ Branch 1 not taken.
2113536 if(!p_igetw(&tempword,f))
18821 {
18822 return qe_invalid;
18823 }
18824
18825 2113536 combo_aliases[j].combo = tempword;
18826
18827
1/2
✓ Branch 0 taken 2113536 times.
✗ Branch 1 not taken.
2113536 if(!p_getc(&tempbyte,f))
18828 {
18829 return qe_invalid;
18830 }
18831
18832 2113536 combo_aliases[j].cset = tempbyte;
18833
18834
1/2
✓ Branch 0 taken 2113536 times.
✗ Branch 1 not taken.
2113536 if(!p_getc(&width,f))
18835 {
18836 return qe_invalid;
18837 }
18838
18839
1/2
✓ Branch 0 taken 2113536 times.
✗ Branch 1 not taken.
2113536 if(!p_getc(&height,f))
18840 {
18841 return qe_invalid;
18842 }
18843
18844
1/2
✓ Branch 0 taken 2113536 times.
✗ Branch 1 not taken.
2113536 if(!p_getc(&mask,f))
18845 {
18846 return qe_invalid;
18847 }
18848
18849 2113536 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18850
18851 2113536 combo_aliases[j].width = width;
18852 2113536 combo_aliases[j].height = height;
18853 2113536 combo_aliases[j].layermask = mask;
18854 2113536 combo_aliases[j].combos.clear();
18855 2113536 combo_aliases[j].csets.clear();
18856
18857
2/2
✓ Branch 0 taken 2170228 times.
✓ Branch 1 taken 2113536 times.
4283764 for(int32_t k=0; k<count; k++)
18858 {
18859
1/2
✓ Branch 0 taken 2170228 times.
✗ Branch 1 not taken.
2170228 if(!p_igetw(&tempword,f))
18860 {
18861 return qe_invalid;
18862 }
18863
18864 2170228 combo_aliases[j].combos[k] = tempword;
18865 2170228 }
18866
18867
2/2
✓ Branch 0 taken 2170228 times.
✓ Branch 1 taken 2113536 times.
4283764 for(int32_t k=0; k<count; k++)
18868 {
18869
1/2
✓ Branch 0 taken 2170228 times.
✗ Branch 1 not taken.
2170228 if(!p_getc(&tempcset,f))
18870 {
18871 return qe_invalid;
18872 }
18873
18874 2170228 combo_aliases[j].csets[k] = tempcset;
18875 2170228 }
18876 2113536 }
18877
18878 //Combo pools!
18879 408 word num_combo_pools = 0;
18880
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 203 times.
408 if(sversion >= 4)
18881 {
18882
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(!p_igetw(&num_combo_pools,f))
18883 {
18884 return qe_invalid;
18885 }
18886 203 }
18887
18888
2/2
✓ Branch 0 taken 3342336 times.
✓ Branch 1 taken 408 times.
3342744 for(combo_pool& pool : combo_pools)
18889 {
18890 3342336 pool.clear();
18891 }
18892
18893 408 combo_pool temp_cpool;
18894
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 408 times.
1098 for(word cp = 0; cp < num_combo_pools; ++cp)
18895 {
18896 690 int32_t num_combos_in_pool = 0;
18897
2/4
✓ Branch 0 taken 690 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 690 times.
✗ Branch 3 not taken.
690 if(!p_igetl(&num_combos_in_pool,f))
18898 {
18899 return qe_invalid;
18900 }
18901
2/2
✓ Branch 0 taken 584 times.
✓ Branch 1 taken 106 times.
690 if(num_combos_in_pool < 1) continue; //nothing to read
18902
18903
1/2
✓ Branch 0 taken 584 times.
✗ Branch 1 not taken.
584 temp_cpool.clear();
18904
18905 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18906
2/2
✓ Branch 0 taken 584 times.
✓ Branch 1 taken 2675 times.
3259 for(auto q = 0; q < num_combos_in_pool; ++q)
18907 {
18908
2/4
✓ Branch 0 taken 2675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2675 times.
✗ Branch 3 not taken.
2675 if(!p_igetl(&cp_cid,f))
18909 {
18910 return qe_invalid;
18911 }
18912
2/4
✓ Branch 0 taken 2675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2675 times.
✗ Branch 3 not taken.
2675 if(!p_getc(&cp_cs,f))
18913 {
18914 return qe_invalid;
18915 }
18916
2/4
✓ Branch 0 taken 2675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2675 times.
✗ Branch 3 not taken.
2675 if(!p_igetw(&cp_quant,f))
18917 {
18918 return qe_invalid;
18919 }
18920
1/2
✓ Branch 0 taken 2675 times.
✗ Branch 1 not taken.
2675 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18921 2675 }
18922
18923
1/2
✓ Branch 0 taken 584 times.
✗ Branch 1 not taken.
584 combo_pools[cp] = temp_cpool;
18924 584 }
18925
18926 //Autocombos!
18927 408 word num_combo_autos = 0;
18928
2/2
✓ Branch 0 taken 191 times.
✓ Branch 1 taken 217 times.
408 if (sversion >= 5)
18929 {
18930
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if (!p_igetw(&num_combo_autos, f))
18931 {
18932 return qe_invalid;
18933 }
18934 191 }
18935
18936
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 3342336 times.
3342744 for (combo_auto& cauto : combo_autos)
18937 {
18938
1/2
✓ Branch 0 taken 3342336 times.
✗ Branch 1 not taken.
3342336 cauto.clear(true);
18939 }
18940
18941
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 combo_auto temp_cauto;
18942
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 408 times.
560 for (word ca = 0; ca < num_combo_autos; ++ca)
18943 {
18944 byte type;
18945 int32_t display_cid, erase_cid;
18946 byte flags, arg;
18947
2/4
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 152 times.
✗ Branch 3 not taken.
152 if (!p_getc(&type, f))
18948 {
18949 return qe_invalid;
18950 }
18951
2/4
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 152 times.
✗ Branch 3 not taken.
152 if (!p_igetl(&display_cid, f))
18952 {
18953 return qe_invalid;
18954 }
18955
2/4
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 152 times.
✗ Branch 3 not taken.
152 if (!p_igetl(&erase_cid, f))
18956 {
18957 return qe_invalid;
18958 }
18959
2/4
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 152 times.
✗ Branch 3 not taken.
152 if (!p_getc(&flags, f))
18960 {
18961 return qe_invalid;
18962 }
18963
2/4
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 152 times.
✗ Branch 3 not taken.
152 if (!p_getc(&arg, f))
18964 {
18965 return qe_invalid;
18966 }
18967 152 int32_t num_combos_in_cauto = 0;
18968
2/4
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 152 times.
✗ Branch 3 not taken.
152 if (!p_igetl(&num_combos_in_cauto, f))
18969 {
18970 return qe_invalid;
18971 }
18972
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 21 times.
152 if (num_combos_in_cauto < 1) continue; //nothing to read
18973
18974
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 temp_cauto.clear();
18975
18976
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 temp_cauto.setType(type);
18977
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 temp_cauto.setDisplay(display_cid);
18978
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 temp_cauto.setEraseCombo(erase_cid);
18979
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 temp_cauto.setFlags(flags);
18980
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 temp_cauto.setArg(arg);
18981
18982 int32_t ca_cid; byte ca_ctype; int16_t ca_offset; int16_t ca_engrave_offset;
18983
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 3377 times.
3508 for (auto q = 0; q < num_combos_in_cauto; ++q)
18984 {
18985
2/4
✓ Branch 0 taken 3377 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3377 times.
✗ Branch 3 not taken.
3377 if (!p_getc(&ca_ctype, f))
18986 {
18987 return qe_invalid;
18988 }
18989
2/4
✓ Branch 0 taken 3377 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3377 times.
✗ Branch 3 not taken.
3377 if (!p_igetl(&ca_cid, f))
18990 {
18991 return qe_invalid;
18992 }
18993
1/2
✓ Branch 0 taken 3377 times.
✗ Branch 1 not taken.
3377 temp_cauto.addEntry(ca_cid, ca_ctype, q, -1);
18994 3377 }
18995
18996
1/2
✓ Branch 0 taken 131 times.
✗ Branch 1 not taken.
131 combo_autos[ca] = temp_cauto;
18997 131 }
18998
18999 408 return 0;
19000 408 }
19001
19002 820 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
19003 {
19004
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 796 times.
820 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_colors);
19005
19006 //these are here to bypass compiler warnings about unused arguments
19007 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
19008 //Capitalized cause it'll save you a headache. -Deedee
19009 820 start_cset=start_cset;
19010 820 max_csets=max_csets;
19011 820 word s_version=0;
19012
19013 miscQdata temp_misc;
19014 820 memcpy(&temp_misc, Misc, sizeof(temp_misc));
19015
19016 byte temp_colordata[48];
19017 char temp_palname[PALNAMESIZE+1];
19018
19019 int32_t dummy;
19020 word palcycles;
19021
19022
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 796 times.
820 if(version > 0x192)
19023 {
19024 //section version info
19025
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_igetw(&s_version,f))
19026 {
19027 return qe_invalid;
19028 }
19029
19030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 796 times.
796 if (s_version > V_CSETS)
19031 return qe_version;
19032
19033 796 FFCore.quest_format[vCSets] = s_version;
19034
19035
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_igetw(&dummy,f))
19036 {
19037 return qe_invalid;
19038 }
19039
19040 //section size
19041
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_igetl(&dummy,f))
19042 {
19043 return qe_invalid;
19044 }
19045 796 }
19046
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 208 times.
820 if (s_version < 5)
19047 {
19048
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 594 times.
✓ Branch 2 taken 588 times.
✓ Branch 3 taken 6 times.
612 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
19049
19050 //finally... section data
19051 612 int32_t q = 0;
19052 612 int32_t p = -15;
19053
2/2
✓ Branch 0 taken 146880 times.
✓ Branch 1 taken 612 times.
147492 for(int32_t i=0; i<oldpdTOTAL; ++i)
19054 {
19055 146880 memset(temp_colordata, 0, 48);
19056
19057
1/2
✓ Branch 0 taken 146880 times.
✗ Branch 1 not taken.
146880 if(!pfread(temp_colordata,48,f))
19058 {
19059 return qe_invalid;
19060 }
19061
19062
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 146640 times.
146880 if (should_skip)
19063 240 continue;
19064
19065 146640 memcpy(&colordata[q*48], temp_colordata, 48);
19066
19067 146640 ++q;
19068
8/8
✓ Branch 0 taken 136864 times.
✓ Branch 1 taken 9776 times.
✓ Branch 2 taken 10387 times.
✓ Branch 3 taken 126477 times.
✓ Branch 4 taken 1222 times.
✓ Branch 5 taken 9165 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1186 times.
146640 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
19069 {
19070
1/2
✓ Branch 0 taken 10351 times.
✗ Branch 1 not taken.
10351 if (s_version < 5) //Bumping up the size of level palettes
19071 {
19072 10351 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
19073 10351 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
19074 10351 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
19075 10351 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
19076 10351 q+=4;
19077 10351 }
19078 else
19079 {
19080 for(int m = 0; m < 4; ++m)
19081 {
19082 memset(temp_colordata, 0, 48);
19083 if(!pfread(temp_colordata,48,f))
19084 {
19085 return qe_invalid;
19086 }
19087 memcpy(&colordata[q*48], temp_colordata, 48);
19088 ++q;
19089 }
19090 }
19091 10351 }
19092 146640 ++p;
19093 146640 }
19094
19095
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 594 times.
612 if(RealOldVerion)
19096 {
19097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
19098 {
19099 18 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
19100 18 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
19101 18 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
19102 18 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
19103 18 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
19104 18 memset(colordata+((poSPRITE255+8)*48), 0, 48);
19105 18 }
19106 18 }
19107 else
19108 {
19109 594 memset(temp_colordata, 0, 48);
19110
19111
2/2
✓ Branch 0 taken 1861002 times.
✓ Branch 1 taken 594 times.
1861596 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
19112 {
19113
1/2
✓ Branch 0 taken 1861002 times.
✗ Branch 1 not taken.
1861002 if(!pfread(temp_colordata,48,f))
19114 {
19115 return qe_invalid;
19116 }
19117
19118
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 1857869 times.
1861002 if (should_skip)
19119 3133 continue;
19120
19121 1857869 memcpy(&colordata[q*48], temp_colordata, 48);
19122
19123 1857869 ++q;
19124
7/8
✓ Branch 0 taken 1857869 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 142913 times.
✓ Branch 3 taken 1714956 times.
✓ Branch 4 taken 1186 times.
✓ Branch 5 taken 141727 times.
✓ Branch 6 taken 1058 times.
✓ Branch 7 taken 128 times.
1857869 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
19125 {
19126
1/2
✓ Branch 0 taken 142785 times.
✗ Branch 1 not taken.
142785 if (s_version < 5) //Bumping up the size of level palettes
19127 {
19128 142785 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
19129 142785 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
19130 142785 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
19131 142785 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
19132 142785 q+=4;
19133 142785 }
19134 else
19135 {
19136 for(int m = 0; m < 4; ++m)
19137 {
19138 memset(temp_colordata, 0, 48);
19139 if(!pfread(temp_colordata,48,f))
19140 {
19141 return qe_invalid;
19142 }
19143 memcpy(&colordata[q*48], temp_colordata, 48);
19144 ++q;
19145 }
19146 }
19147 142785 }
19148 1857869 ++p;
19149 1857869 }
19150
19151
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 529 times.
594 if(s_version < 4)
19152 {
19153
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 64 times.
65 if (!should_skip)
19154 {
19155 64 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
19156 64 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
19157 64 }
19158 65 }
19159 else
19160 {
19161
2/2
✓ Branch 0 taken 1760512 times.
✓ Branch 1 taken 529 times.
1761041 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
19162 {
19163
1/2
✓ Branch 0 taken 1760512 times.
✗ Branch 1 not taken.
1760512 if(!pfread(temp_colordata,48,f))
19164 {
19165 return qe_invalid;
19166 }
19167
19168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1760512 times.
1760512 if (should_skip)
19169 continue;
19170
19171 1760512 memcpy(&colordata[q*48], temp_colordata, 48);
19172 1760512 ++q;
19173
5/6
✓ Branch 0 taken 1760512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135424 times.
✓ Branch 3 taken 1625088 times.
✓ Branch 4 taken 1058 times.
✓ Branch 5 taken 134366 times.
1760512 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
19174 {
19175
1/2
✓ Branch 0 taken 134366 times.
✗ Branch 1 not taken.
134366 if (s_version < 5) //Bumping up the size of level palettes
19176 {
19177 134366 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
19178 134366 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
19179 134366 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
19180 134366 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
19181 134366 q+=4;
19182 134366 }
19183 else
19184 {
19185 for(int m = 0; m < 4; ++m)
19186 {
19187 memset(temp_colordata, 0, 48);
19188 if(!pfread(temp_colordata,48,f))
19189 {
19190 return qe_invalid;
19191 }
19192 memcpy(&colordata[q*48], temp_colordata, 48);
19193 ++q;
19194 }
19195 }
19196 134366 }
19197 1760512 ++p;
19198 1760512 }
19199
19200 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
19201 }
19202 }
19203 612 }
19204 else
19205 {
19206
2/2
✓ Branch 0 taken 1819792 times.
✓ Branch 1 taken 208 times.
1820000 for(int32_t i=0; i<pdTOTAL255; ++i)
19207 {
19208 1819792 memset(temp_colordata, 0, 48);
19209
19210
1/2
✓ Branch 0 taken 1819792 times.
✗ Branch 1 not taken.
1819792 if(!pfread(temp_colordata,48,f))
19211 {
19212 return qe_invalid;
19213 }
19214
19215 1819792 memcpy(&colordata[i*48], temp_colordata, 48);
19216 1819792 }
19217 }
19218
19219
4/4
✓ Branch 0 taken 819 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 163 times.
✓ Branch 3 taken 656 times.
820 if (!should_skip && s_version < 6)
19220 {
19221
2/2
✓ Branch 0 taken 275488512 times.
✓ Branch 1 taken 656 times.
275489168 for (int i = 0; i < psTOTAL255; i++)
19222 {
19223 275488512 colordata[i] = _rgb_scale_6[colordata[i]];
19224 275488512 }
19225 656 }
19226
19227
5/6
✓ Branch 0 taken 802 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 796 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
820 if((version < 0x192)||((version == 0x192)&&(build<76)))
19228 {
19229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
19230 18 init_palnames();
19231 18 }
19232 else
19233 {
19234 802 int32_t palnamestoread = 0;
19235
19236
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 737 times.
802 if(s_version < 3)
19237 65 palnamestoread = OLDMAXLEVELS;
19238 else
19239 737 palnamestoread = 512;
19240
19241
2/2
✓ Branch 0 taken 393984 times.
✓ Branch 1 taken 802 times.
394786 for(int32_t i=0; i<palnamestoread; ++i)
19242 {
19243
1/2
✓ Branch 0 taken 393984 times.
✗ Branch 1 not taken.
393984 if(!p_getstr(temp_palname,PALNAMESIZE,f))
19244 {
19245 return qe_invalid;
19246 }
19247
19248
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 393728 times.
393984 if (!should_skip)
19249 393728 memcpy(palnames[i], temp_palname, PALNAMESIZE);
19250 393984 }
19251
19252
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 801 times.
802 if (should_skip)
19253 1 return 0;
19254
19255
2/2
✓ Branch 0 taken 16384 times.
✓ Branch 1 taken 801 times.
17185 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
19256 {
19257 16384 memset(palnames[i], 0, PALNAMESIZE);
19258 16384 }
19259 }
19260
19261
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 796 times.
819 if(version > 0x192)
19262 {
19263
2/2
✓ Branch 0 taken 203776 times.
✓ Branch 1 taken 796 times.
204572 for(int32_t i=0; i<256; i++)
19264 {
19265
2/2
✓ Branch 0 taken 611328 times.
✓ Branch 1 taken 203776 times.
815104 for(int32_t j=0; j<3; j++)
19266 {
19267 611328 temp_misc.cycles[i][j].first=0;
19268 611328 temp_misc.cycles[i][j].count=0;
19269 611328 temp_misc.cycles[i][j].speed=0;
19270 611328 }
19271 203776 }
19272
19273
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_igetw(&palcycles,f))
19274 {
19275 return qe_invalid;
19276 }
19277
19278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 796 times.
796 if (palcycles > NUM_PAL_CYCLES)
19279 {
19280 return qe_invalid;
19281 }
19282
19283
2/2
✓ Branch 0 taken 22295 times.
✓ Branch 1 taken 796 times.
23091 for(int32_t i=0; i<palcycles; i++)
19284 {
19285
2/2
✓ Branch 0 taken 66885 times.
✓ Branch 1 taken 22295 times.
89180 for(int32_t j=0; j<3; j++)
19286 {
19287
1/2
✓ Branch 0 taken 66885 times.
✗ Branch 1 not taken.
66885 if(!p_getc(&temp_misc.cycles[i][j].first,f))
19288 {
19289 return qe_invalid;
19290 }
19291 66885 }
19292
19293
2/2
✓ Branch 0 taken 66885 times.
✓ Branch 1 taken 22295 times.
89180 for(int32_t j=0; j<3; j++)
19294 {
19295
1/2
✓ Branch 0 taken 66885 times.
✗ Branch 1 not taken.
66885 if(!p_getc(&temp_misc.cycles[i][j].count,f))
19296 {
19297 return qe_invalid;
19298 }
19299 66885 }
19300
19301
2/2
✓ Branch 0 taken 66885 times.
✓ Branch 1 taken 22295 times.
89180 for(int32_t j=0; j<3; j++)
19302 {
19303
1/2
✓ Branch 0 taken 66885 times.
✗ Branch 1 not taken.
66885 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
19304 {
19305 return qe_invalid;
19306 }
19307 66885 }
19308 22295 }
19309
19310 796 memcpy(Misc, &temp_misc, sizeof(temp_misc));
19311 796 }
19312
19313 819 return 0;
19314 820 }
19315
19316 820 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
19317 {
19318
2/2
✓ Branch 0 taken 796 times.
✓ Branch 1 taken 24 times.
820 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_tiles);
19319
19320 820 int32_t tiles_used=0;
19321 820 word section_version = 0;
19322 820 int32_t section_size= 0;
19323 820 byte *temp_tile = new byte[tilesize(tf32Bit)];
19324
19325 //Tile Expansion
19326 //if ( version >= 0x254 && build >= 41 )
19327
4/4
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 208 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 606 times.
820 if (version < 0x254 && build < 41)
19328 {
19329 606 max_tiles = ZC250MAXTILES;
19330 606 }
19331
19332
19333
2/6
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 820 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
820 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19334 {
19335 if(!init_tiles_for_190(true, Header))
19336 {
19337 al_trace("Unable to initialize tiles\n");
19338 }
19339
19340 delete[] temp_tile;
19341 temp_tile=NULL;
19342 return 0;
19343 }
19344 else
19345 {
19346
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 796 times.
820 if(version > 0x192)
19347 {
19348 //section version info
19349
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_igetw(&section_version,f))
19350 {
19351 delete[] temp_tile;
19352 return qe_invalid;
19353 }
19354
19355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 796 times.
796 if (section_version > V_TILES)
19356 return qe_version;
19357
19358 796 FFCore.quest_format[vTiles] = section_version;
19359
19360
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!read_deprecated_section_cversion(f))
19361 {
19362 delete[] temp_tile;
19363 return qe_invalid;
19364 }
19365
19366 //section size
19367
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 if(!p_igetl(&section_size,f))
19368 {
19369 delete[] temp_tile;
19370 return qe_invalid;
19371 }
19372 796 }
19373
19374 //if ( build < 41 )
19375 //{
19376 // tiles_used = ZC250MAXTILES;
19377 //}
19378
19379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 820 times.
820 if(version < 0x174)
19380 {
19381 tiles_used=TILES_PER_PAGE*4;
19382 } //no expanded tile space
19383
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 802 times.
820 else if(version < 0x191)
19384 {
19385 18 tiles_used=OLDMAXTILES;
19386 18 }
19387 else
19388 {
19389 //finally... section data
19390
3/4
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 594 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 208 times.
802 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19391 {
19392
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 if(!p_igetl(&tiles_used,f))
19393 {
19394 delete[] temp_tile;
19395 return qe_invalid;
19396 }
19397 208 }
19398 else
19399 {
19400
1/2
✓ Branch 0 taken 594 times.
✗ Branch 1 not taken.
594 if(!p_igetw(&tiles_used,f))
19401 {
19402 delete[] temp_tile;
19403 return qe_invalid;
19404 }
19405 }
19406 }
19407
19408
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 tiles_used=zc_min(tiles_used, max_tiles);
19409
19410 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19411 //if ( version < 0x254 && build < 41 )
19412
3/6
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 208 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
820 if ( version < 0x254 || (version == 0x254 && build < 41) )
19413 //if ( build < 41 )
19414 {
19415
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19416 612 }
19417 else //2.55
19418 {
19419
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19420 }
19421
19422 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19423
19424
19425
2/2
✓ Branch 0 taken 19027028 times.
✓ Branch 1 taken 820 times.
19027848 for(int32_t i=0; i<tiles_used; ++i)
19426 {
19427 19027028 byte format=tf4Bit;
19428 19027028 memset(temp_tile, 0, tilesize(tf32Bit));
19429
19430
3/6
✓ Branch 0 taken 2985456 times.
✓ Branch 1 taken 16041572 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2985456 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
19027028 if((version>0x211)||((version==0x211)&&(build>4)))
19431 {
19432
1/2
✓ Branch 0 taken 16041572 times.
✗ Branch 1 not taken.
16041572 if(!p_getc(&format,f))
19433 {
19434 delete[] temp_tile;
19435 return qe_invalid;
19436 }
19437 16041572 }
19438
4/4
✓ Branch 0 taken 8088022 times.
✓ Branch 1 taken 10939006 times.
✓ Branch 2 taken 3750438 times.
✓ Branch 3 taken 4337584 times.
19027028 if(section_version > 2 && !format)
19439 {
19440 4337584 reset_tile(buf,start_tile+i,tf4Bit);
19441 4337584 continue;
19442 }
19443
19444
2/2
✓ Branch 0 taken 14182150 times.
✓ Branch 1 taken 507294 times.
14689444 int size = format == tf4Bit ? 128 : tilesize(format);
19445
1/2
✓ Branch 0 taken 14689444 times.
✗ Branch 1 not taken.
14689444 if(!pfread(temp_tile,size,f))
19446 {
19447 delete[] temp_tile;
19448 return qe_invalid;
19449 }
19450
19451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14689444 times.
14689444 if (should_skip)
19452 continue;
19453
19454 14689444 buf[start_tile+i].format=format;
19455
19456
2/2
✓ Branch 0 taken 14485559 times.
✓ Branch 1 taken 203885 times.
14689444 if(buf[start_tile+i].data)
19457 {
19458 14485559 free(buf[start_tile+i].data);
19459 14485559 buf[start_tile+i].data=NULL;
19460 14485559 }
19461
19462 14689444 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19463
19464
2/2
✓ Branch 0 taken 14182150 times.
✓ Branch 1 taken 507294 times.
14689444 if (format == tf4Bit)
19465 {
19466 byte temp[256];
19467 14182150 byte *si = temp_tile + 128;
19468 14182150 byte *di = temp + 256;
19469
19470
2/2
✓ Branch 0 taken 1815315200 times.
✓ Branch 1 taken 14182150 times.
1829497350 for(int i=127; i>=0; --i)
19471 {
19472 1815315200 (*(--di)) = (*(--si)) >> 4;
19473 1815315200 (*(--di)) = (*si) & 15;
19474 1815315200 }
19475
19476 14182150 memcpy(buf[start_tile+i].data,temp,256);
19477 14182150 }
19478 else
19479 {
19480 507294 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19481 }
19482 14689444 }
19483 }
19484
19485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 820 times.
820 if (should_skip)
19486 return 0;
19487
19488
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 612 times.
820 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19489 {
19490
2/2
✓ Branch 0 taken 91175760 times.
✓ Branch 1 taken 612 times.
91176372 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19491 {
19492
19493 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19494 91175760 reset_tile(buf,q,tf4Bit);
19495
19496
19497 /*
19498
19499 byte tempbyte;
19500 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19501 {
19502 tempbyte=buf[ZC250MAXTILES-1].data[i];
19503 buf[q].data[i] = tempbyte;
19504 }
19505 //int32_t temp = tempbyte=buf[130].data[i];
19506 //buf[q].data = buf[ZC250MAXTILES-1].data;
19507 */
19508 //reset_tile(buf,q,tf4Bit);
19509 91175760 }
19510
19511 612 }
19512
19513
4/6
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 208 times.
820 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19514 {
19515
2/2
✓ Branch 0 taken 30626830 times.
✓ Branch 1 taken 612 times.
30627442 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19516 {
19517 30626830 reset_tile(buf,i,tf4Bit);
19518 30626830 }
19519 612 }
19520 else
19521 {
19522
2/2
✓ Branch 0 taken 35954262 times.
✓ Branch 1 taken 208 times.
35954470 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19523 {
19524 35954262 reset_tile(buf,i,tf4Bit);
19525 35954262 }
19526 }
19527
19528
5/6
✓ Branch 0 taken 802 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 796 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
820 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19529 {
19530
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(get_qr(qr_BSZELDA)) //
19531 {
19532 byte tempbyte;
19533 6 int32_t floattile=wpnsbuf[iwSwim].tile;
19534
19535
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19536 {
19537 1536 tempbyte=buf[23].data[i];
19538 1536 buf[23].data[i]=buf[24].data[i];
19539 1536 buf[24].data[i]=buf[25].data[i];
19540 1536 buf[25].data[i]=buf[26].data[i];
19541 1536 buf[26].data[i]=tempbyte;
19542 1536 }
19543 //swim tiles are out of order, too, but nobody cared? -Z
19544
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19545 {
19546 1536 tempbyte=buf[floattile+11].data[i];
19547 1536 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19548 1536 buf[floattile+12].data[i]=tempbyte;
19549 1536 }
19550 6 }
19551 24 }
19552
19553
3/6
✓ Branch 0 taken 737 times.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 737 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
820 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19554 {
19555
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 22 times.
83 if(!get_qr(qr_NEWENEMYTILES))
19556 {
19557 byte tempbyte;
19558
19559
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19560 {
19561 5632 tempbyte=buf[130].data[i];
19562 5632 buf[130].data[i]=buf[132].data[i];
19563 5632 buf[132].data[i]=tempbyte;
19564
19565 5632 tempbyte=buf[131].data[i];
19566 5632 buf[131].data[i]=buf[133].data[i];
19567 5632 buf[133].data[i]=tempbyte;
19568 5632 }
19569 22 }
19570 83 }
19571
19572 820 al_trace("Registering blank tiles\n");
19573 820 register_blank_tiles();
19574
19575 //memset(temp_tile, 0, tilesize(tf32Bit));
19576
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 delete[] temp_tile;
19577 820 temp_tile=NULL;
19578 820 return 0;
19579 820 }
19580
19581 490 int32_t readmidis(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19582 {
19583
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 467 times.
490 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_midis);
19584
19585 static byte fake_midi_flags[32];
19586
19587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 490 times.
490 byte *mf=should_skip ? fake_midi_flags : midi_flags;
19588 int32_t dummy;
19589 word dummy2;
19590 // zcmidi_ temp_midi;
19591 int32_t tunes_to_read;
19592 490 int32_t tune_count=0;
19593 490 word section_version=0;
19594 490 zctune temp;
19595
19596
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 467 times.
490 if(Header->zelda_version < 0x193)
19597 {
19598 // mf=Header->data_flags+ZQ_MIDIS2;
19599
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
23 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19600 {
19601 22 tunes_to_read=MAXCUSTOMMIDIS192b177;
19602 22 }
19603 else
19604 {
19605 1 tunes_to_read=MAXCUSTOMTUNES;
19606 }
19607 23 }
19608 else
19609 {
19610 //section version info
19611
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if(!p_igetw(&section_version,f))
19612 {
19613 return qe_invalid;
19614 }
19615
19616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if (section_version > V_MIDIS)
19617 return qe_version;
19618
19619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if (!should_skip)
19620 467 FFCore.quest_format[vMIDIs] = section_version;
19621
19622
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if(!p_igetw(&dummy2,f))
19623 {
19624 return qe_invalid;
19625 }
19626
19627 //section size
19628
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if(!p_igetl(&dummy,f))
19629 {
19630 return qe_invalid;
19631 }
19632
19633 //finally... section data
19634
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if(!pfread(midi_flags,sizeof(midi_flags),f))
19635 {
19636 return qe_invalid;
19637 }
19638
19639 467 tunes_to_read=MAXCUSTOMTUNES;
19640 }
19641
19642
2/2
✓ Branch 0 taken 123480 times.
✓ Branch 1 taken 490 times.
123970 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19643 {
19644
2/2
✓ Branch 0 taken 10300 times.
✓ Branch 1 taken 113180 times.
123480 if(get_bit(mf, i))
19645 {
19646 10300 ++tune_count;
19647 10300 }
19648 123480 }
19649
19650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 490 times.
490 if (!should_skip)
19651 490 reset_tunes(tunes); //reset_midis(midis);
19652
19653
2/2
✓ Branch 0 taken 118640 times.
✓ Branch 1 taken 490 times.
119130 for(int32_t i=0; i<tunes_to_read; i++)
19654 {
19655 118640 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19656
19657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118640 times.
118640 if (!should_skip)
19658 118640 tunes[i].reset(); // reset_midi(midis+i);
19659
19660
2/2
✓ Branch 0 taken 108340 times.
✓ Branch 1 taken 10300 times.
118640 if(get_bit(mf,i))
19661 {
19662
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7637 times.
10300 if(section_version < 4)
19663 {
19664
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if(!p_getstr(temp.title,20,f))
19665 {
19666 return qe_invalid;
19667 }
19668 2663 }
19669 else
19670 {
19671
1/2
✓ Branch 0 taken 7637 times.
✗ Branch 1 not taken.
7637 if(!p_getstr(temp.title,sizeof(temp.title)-1,f))
19672 {
19673 return qe_invalid;
19674 }
19675 }
19676
19677
1/2
✓ Branch 0 taken 10300 times.
✗ Branch 1 not taken.
10300 if(!p_igetl(&temp.start,f))
19678 {
19679 return qe_invalid;
19680 }
19681
19682
1/2
✓ Branch 0 taken 10300 times.
✗ Branch 1 not taken.
10300 if(!p_igetl(&temp.loop_start,f))
19683 {
19684 return qe_invalid;
19685 }
19686
19687
1/2
✓ Branch 0 taken 10300 times.
✗ Branch 1 not taken.
10300 if(!p_igetl(&temp.loop_end,f))
19688 {
19689 return qe_invalid;
19690 }
19691
19692
1/2
✓ Branch 0 taken 10300 times.
✗ Branch 1 not taken.
10300 if(!p_igetw(&temp.loop,f))
19693 {
19694 return qe_invalid;
19695 }
19696
19697
1/2
✓ Branch 0 taken 10300 times.
✗ Branch 1 not taken.
10300 if(!p_igetw(&temp.volume,f))
19698 {
19699 return qe_invalid;
19700 }
19701
19702
2/2
✓ Branch 0 taken 10051 times.
✓ Branch 1 taken 249 times.
10300 if(Header->zelda_version < 0x193)
19703 {
19704
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(!p_igetl(&dummy,f))
19705 {
19706 return qe_invalid;
19707 }
19708 249 }
19709
19710
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7637 times.
10300 if(section_version >= 3)
19711 {
19712
1/2
✓ Branch 0 taken 7637 times.
✗ Branch 1 not taken.
7637 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19713 {
19714 return qe_invalid;
19715 }
19716 7637 }
19717
19718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10300 times.
10300 if (!should_skip)
19719 10300 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19720
19721
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7637 times.
10300 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19722 {
19723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2663 times.
2663 if (should_skip)
19724 {
19725 if (read_midi(f)==NULL)
19726 {
19727 return qe_invalid;
19728 }
19729
19730 continue;
19731 }
19732
19733 // old format - a midi is a midi
19734
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if((tunes[i].data=read_midi(f))==NULL)
19735 {
19736 return qe_invalid;
19737 }
19738 2663 }
19739 else
19740 {
19741 byte format;
19742
1/2
✓ Branch 0 taken 7637 times.
✗ Branch 1 not taken.
7637 if(!pfread(&format,sizeof(format),f))
19743 {
19744 return qe_invalid;
19745 }
19746
19747 // MIDI is the only format saved here.
19748 // Never did more than MIDI for a zctune, and no plans to now.
19749
1/2
✓ Branch 0 taken 7637 times.
✗ Branch 1 not taken.
7637 if (format != MFORMAT_MIDI)
19750 {
19751 return qe_invalid;
19752 }
19753
19754 7637 tunes[i].data = read_midi(f);
19755
1/2
✓ Branch 0 taken 7637 times.
✗ Branch 1 not taken.
7637 if (!tunes[i].data)
19756 {
19757 return qe_invalid;
19758 }
19759 }
19760 10300 }
19761 118640 }
19762
19763 490 return 0;
19764 490 }
19765
19766 490 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19767 {
19768
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 23 times.
490 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_cheats);
19769
19770 int32_t dummy;
19771 ZCHEATS tempzcheats;
19772 490 char temp_use_cheats=1;
19773 490 memset(&tempzcheats, 0, sizeof(tempzcheats));
19774 490 word s_version = 0;
19775
19776
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 467 times.
490 if(Header->zelda_version > 0x192)
19777 {
19778 //section version info
19779
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if(!p_igetw(&s_version,f))
19780 {
19781 return qe_invalid;
19782 }
19783
19784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if (s_version > V_CHEATS)
19785 return qe_version;
19786
19787 467 FFCore.quest_format[vCheats] = s_version;
19788
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if(!p_igetw(&dummy,f))
19789 {
19790 return qe_invalid;
19791 }
19792
19793 //section size
19794
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if(!p_igetl(&dummy,f))
19795 {
19796 return qe_invalid;
19797 }
19798
19799 //finally... section data
19800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if(!p_getc(&temp_use_cheats,f))
19801 {
19802 return qe_invalid;
19803 }
19804 467 }
19805
19806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 490 times.
490 if(Header->data_flags[ZQ_CHEATS2])
19807 {
19808
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 if(!p_igetl(&tempzcheats.flags,f))
19809 {
19810 return qe_invalid;
19811 }
19812
19813
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19814 {
19815 return qe_invalid;
19816 }
19817 490 }
19818
19819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 490 times.
490 if (should_skip)
19820 return 0;
19821
19822 490 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19823 490 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19824
19825 490 return 0;
19826 490 }
19827
19828 299 int32_t readinitdata_old(PACKFILE *f, zquestheader *Header, word s_version, zinitdata& temp_zinit)
19829 {
19830
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 276 times.
299 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
19831
19832 byte padding, tempbyte;
19833
19834 // Legacy item properties (now integrated into itemdata)
19835 byte sword_hearts[4];
19836 byte beam_hearts[4];
19837 299 byte beam_percent=0;
19838 word beam_power[4];
19839 299 byte hookshot_length=99;
19840 299 byte hookshot_links=100;
19841 299 byte longshot_length=99;
19842 299 byte longshot_links=100;
19843 299 byte moving_fairy_hearts=3;
19844 299 byte moving_fairy_heart_percent=0;
19845 299 byte stationary_fairy_hearts=3;
19846 299 byte stationary_fairy_heart_percent=0;
19847 299 byte moving_fairy_magic=0;
19848 299 byte moving_fairy_magic_percent=0;
19849 299 byte stationary_fairy_magic=0;
19850 299 byte stationary_fairy_magic_percent=0;
19851 299 byte blue_potion_hearts=100;
19852 299 byte blue_potion_heart_percent=1;
19853 299 byte red_potion_hearts=100;
19854 299 byte red_potion_heart_percent=1;
19855 299 byte blue_potion_magic=100;
19856 299 byte blue_potion_magic_percent=1;
19857 299 byte red_potion_magic=100;
19858 299 byte red_potion_magic_percent=1;
19859
19860 299 byte bomb_ratio = 4;
19861
19862 299 subscr_mode = 0;
19863
19864 /* HIGHLY UNORTHODOX UPDATING THING, by L
19865 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19866 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19867 * changing from 13 to 14.
19868 */
19869
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
299 if(s_version < 14)
19870 82 fixpolsvoice=true;
19871
19872 /* End highly unorthodox updating thing */
19873
19874
4/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 111 times.
299 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19875 111 temp_zinit.jump_hero_layer_threshold=0;
19876
19877
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 217 times.
299 if(s_version >= 10)
19878 {
19879 char temp;
19880
19881 //new-style items
19882
2/2
✓ Branch 0 taken 55552 times.
✓ Branch 1 taken 217 times.
55769 for(int32_t j=0; j<256; j++)
19883 {
19884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55552 times.
55552 if(!p_getc(&temp,f))
19885 return qe_invalid;
19886
19887 55552 temp_zinit.set_item(j, temp != 0);
19888 55552 }
19889 217 }
19890
19891
5/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
299 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19892 {
19893 char temp;
19894
19895 //finally... section data
19896
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version > 0x192)||
19897 //new only
19898
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19899 {
19900 //OLD-style items... sigh
19901
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 60 times.
277 if(s_version < 10)
19902 {
19903
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19904 {
19905 return qe_invalid;
19906 }
19907
19908 60 temp_zinit.set_item(iRaft, temp != 0);
19909
19910
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19911 {
19912 return qe_invalid;
19913 }
19914
19915 60 temp_zinit.set_item(iLadder, temp != 0);
19916
19917
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19918 {
19919 return qe_invalid;
19920 }
19921
19922 60 temp_zinit.set_item(iBook, temp != 0);
19923
19924
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19925 {
19926 return qe_invalid;
19927 }
19928
19929 60 temp_zinit.set_item(iMKey, temp != 0);
19930
19931
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19932 {
19933 return qe_invalid;
19934 }
19935
19936 60 temp_zinit.set_item(iFlippers, temp != 0);
19937
19938
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19939 {
19940 return qe_invalid;
19941 }
19942
19943 60 temp_zinit.set_item(iBoots, temp != 0);
19944 60 }
19945 277 }
19946
19947
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version < 10)
19948 {
19949 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19950
19951
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempring,f))
19952 {
19953 return qe_invalid;
19954 }
19955
19956
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempsword,f))
19957 {
19958 return qe_invalid;
19959 }
19960
19961
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempshield,f))
19962 {
19963 return qe_invalid;
19964 }
19965
19966
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwallet,f))
19967 {
19968 return qe_invalid;
19969 }
19970
19971
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbracelet,f))
19972 {
19973 return qe_invalid;
19974 }
19975
19976
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempamulet,f))
19977 {
19978 return qe_invalid;
19979 }
19980
19981
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbow,f))
19982 {
19983 return qe_invalid;
19984 }
19985
19986 //old only
19987
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
19988 {
19989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempring=(tempring)?(1<<(tempring-1)):0;
19990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19991
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19996 4 }
19997
19998 //rings start at level 2... wtf
19999 //account for this -DD
20000 64 tempring <<= 1;
20001 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
20002 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
20003 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
20004 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
20005 //bracelet ALSO starts at level 2 :-( -DD
20006 64 tempbracelet<<=1;
20007 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
20008 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
20009 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
20010
20011 //new only
20012
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
64 if((Header->zelda_version == 0x192)&&(Header->build>173))
20013 {
20014
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
20015 {
20016
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
20017 {
20018 return qe_invalid;
20019 }
20020 32 }
20021 1 }
20022
20023 char tempcandle, tempboomerang, temparrow, tempwhistle;
20024
20025
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempcandle,f))
20026 {
20027 return qe_invalid;
20028 }
20029
20030
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempboomerang,f))
20031 {
20032 return qe_invalid;
20033 }
20034
20035
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temparrow,f))
20036 {
20037 return qe_invalid;
20038 }
20039
20040
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temp,f))
20041 {
20042 return qe_invalid;
20043 }
20044
20045 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
20046
20047
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwhistle,f))
20048 {
20049 return qe_invalid;
20050 }
20051
20052 //old only
20053
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
20054 {
20055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
20056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
20057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 temparrow=(temparrow)?(1<<(temparrow-1)):0;
20058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
20059 4 }
20060
20061 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
20062 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
20063 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
20064 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
20065 //What about the potion...?
20066
20067 64 }
20068
20069
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if(s_version < 29)
20070 {
20071 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
20072 //to jab out my eye...
20073
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(!p_getc(&padding,f))
20074 return qe_invalid;
20075 264 temp_zinit.counter[crBOMBS] = padding;
20076
20077
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(!p_getc(&padding,f))
20078 return qe_invalid;
20079 264 temp_zinit.counter[crSBOMBS] = padding;
20080 264 }
20081
20082 //Back to more OLD item code
20083
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version < 10)
20084 {
20085
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
69 if((Header->zelda_version > 0x192)||
20086 //new only
20087
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20088 {
20089
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20090 {
20091 return qe_invalid;
20092 }
20093
20094 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
20095
20096
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20097 {
20098 return qe_invalid;
20099 }
20100
20101 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
20102
20103
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20104 {
20105 return qe_invalid;
20106 }
20107
20108 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
20109
20110
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20111 {
20112 return qe_invalid;
20113 }
20114
20115 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
20116
20117
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20118 {
20119 return qe_invalid;
20120 }
20121
20122 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
20123
20124
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20125 {
20126 return qe_invalid;
20127 }
20128
20129 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
20130
20131
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20132 {
20133 return qe_invalid;
20134 }
20135
20136 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
20137
20138
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20139 {
20140 return qe_invalid;
20141 }
20142
20143 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
20144
20145
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20146 {
20147 return qe_invalid;
20148 }
20149
20150 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
20151
20152
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
20153 {
20154 return qe_invalid;
20155 }
20156
20157
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1 times.
60 if(Header->zelda_version == 0x192)
20158 {
20159
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
20160 {
20161
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
20162 {
20163 return qe_invalid;
20164 }
20165 32 }
20166 1 }
20167 60 }
20168 64 }
20169
20170 //old only
20171
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
281 if((Header->zelda_version == 0x192)&&(Header->build<174))
20172 {
20173 byte equipment, tmpitm; //bit flags
20174
20175
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&equipment,f))
20176 {
20177 return qe_invalid;
20178 }
20179
20180 4 temp_zinit.set_item(iRaft, get_bit(&equipment, idE_RAFT)!=0);
20181 4 temp_zinit.set_item(iLadder, get_bit(&equipment, idE_LADDER)!=0);
20182 4 temp_zinit.set_item(iBook, get_bit(&equipment, idE_BOOK)!=0);
20183 4 temp_zinit.set_item(iMKey, get_bit(&equipment, idE_KEY)!=0);
20184 4 temp_zinit.set_item(iFlippers, get_bit(&equipment, idE_FLIPPERS)!=0);
20185 4 temp_zinit.set_item(iBoots, get_bit(&equipment, idE_BOOTS)!=0);
20186
20187
20188
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tmpitm,f))
20189 {
20190 return qe_invalid;
20191 }
20192
20193 4 temp_zinit.set_item(iWand, get_bit(&tmpitm, idI_WAND)!=0);
20194 4 temp_zinit.set_item(iLetter, get_bit(&tmpitm, idI_LETTER)!=0);
20195 4 temp_zinit.set_item(iLens, get_bit(&tmpitm, idI_LENS)!=0);
20196 4 temp_zinit.set_item(iHookshot, get_bit(&tmpitm, idI_HOOKSHOT)!=0);
20197 4 temp_zinit.set_item(iBait, get_bit(&tmpitm, idI_BAIT)!=0);
20198 4 temp_zinit.set_item(iHammer, get_bit(&tmpitm, idI_HAMMER)!=0);
20199 4 }
20200
20201
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&tempbyte,f))
20202 return qe_invalid;
20203 281 temp_zinit.mcounter[crLIFE] = tempbyte;
20204
20205
20206
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version < 14)
20207 {
20208 byte temphp;
20209
20210
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
20211 {
20212 return qe_invalid;
20213 }
20214
20215 64 temp_zinit.counter[crLIFE]=temphp;
20216
20217
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
20218 {
20219 return qe_invalid;
20220 }
20221
20222 64 temp_zinit.cont_heart=temphp;
20223 64 }
20224 else
20225 {
20226
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.counter[crLIFE],f))
20227 {
20228 return qe_invalid;
20229 }
20230
20231
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.cont_heart,f))
20232 {
20233 return qe_invalid;
20234 }
20235 }
20236
20237
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.hcp,f))
20238 {
20239 return qe_invalid;
20240 }
20241
20242
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version >= 14)
20243 {
20244
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.hcp_per_hc,f))
20245 {
20246 return qe_invalid;
20247 }
20248
20249
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(s_version<16) // July 2007
20250 {
20251 if(get_qr(qr_BRANGPICKUP+1))
20252 temp_zinit.hcp_per_hc = 0xFF;
20253
20254 //Dispose of legacy rule
20255 set_qr(qr_BRANGPICKUP+1, 0);
20256 }
20257 217 }
20258
20259
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if(s_version < 29)
20260 {
20261
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(!p_getc(&padding,f))
20262 return qe_invalid;
20263 264 temp_zinit.mcounter[crBOMBS] = padding;
20264 264 }
20265
20266
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.counter[crKEYS],f))
20267 {
20268 return qe_invalid;
20269 }
20270
20271
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_igetw(&temp_zinit.counter[crMONEY],f))
20272 {
20273 return qe_invalid;
20274 }
20275
20276
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&tempbyte,f))
20277 return qe_invalid;
20278
2/2
✓ Branch 0 taken 2248 times.
✓ Branch 1 taken 281 times.
2529 for(int q = 0; q < 8; ++q)
20279
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 1744 times.
2248 SETFLAG(temp_zinit.litems[q+1], (1 << li_mcguffin), get_bitl(tempbyte, q));
20280
20281 281 int level_count = 32;
20282
3/6
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
281 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20283 217 level_count = 64;
20284 byte tmp_map[64];
20285 byte tmp_compass[64];
20286
2/2
✓ Branch 0 taken 15936 times.
✓ Branch 1 taken 281 times.
16217 for(int32_t i=0; i<level_count; i++)
20287
1/2
✓ Branch 0 taken 15936 times.
✗ Branch 1 not taken.
15936 if(!p_getc(&tmp_map[i],f))
20288 return qe_invalid;
20289
2/2
✓ Branch 0 taken 15936 times.
✓ Branch 1 taken 281 times.
16217 for(int32_t i=0; i<level_count; i++)
20290
1/2
✓ Branch 0 taken 15936 times.
✗ Branch 1 not taken.
15936 if(!p_getc(&tmp_compass[i],f))
20291 return qe_invalid;
20292
2/2
✓ Branch 0 taken 127488 times.
✓ Branch 1 taken 281 times.
127769 for(int q = 0; q < level_count*8; ++q)
20293 {
20294
2/2
✓ Branch 0 taken 796 times.
✓ Branch 1 taken 126692 times.
127488 SETFLAG(temp_zinit.litems[q], (1 << li_map), get_bit(tmp_map, q));
20295
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 127479 times.
127488 SETFLAG(temp_zinit.litems[q], (1 << li_compass), get_bit(tmp_compass, q));
20296 127488 }
20297
20298
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
286 if((Header->zelda_version > 0x192)||
20299 //new only
20300
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20301 {
20302 byte tmp_boss_key[64];
20303
2/2
✓ Branch 0 taken 15808 times.
✓ Branch 1 taken 277 times.
16085 for(int32_t i=0; i<level_count; i++)
20304 {
20305
1/2
✓ Branch 0 taken 15808 times.
✗ Branch 1 not taken.
15808 if(!p_getc(&tmp_boss_key[i],f))
20306 {
20307 return qe_invalid;
20308 }
20309 15808 }
20310
2/2
✓ Branch 0 taken 126464 times.
✓ Branch 1 taken 277 times.
126741 for(int q = 0; q < level_count*8; ++q)
20311 {
20312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126464 times.
126464 SETFLAG(temp_zinit.litems[q], (1 << li_boss_key), get_bit(tmp_boss_key, q));
20313 126464 }
20314 277 }
20315
20316 byte tmpmisc[16];
20317
2/2
✓ Branch 0 taken 4496 times.
✓ Branch 1 taken 281 times.
4777 for(int32_t i=0; i<16; i++)
20318
1/2
✓ Branch 0 taken 4496 times.
✗ Branch 1 not taken.
4496 if(!p_getc(&tmpmisc[i],f))
20319 return qe_invalid;
20320 281 temp_zinit.flags.set(INIT_FL_CONTPERCENT,get_bit(tmpmisc,0));
20321 281 temp_zinit.magicdrainrate = get_bit(tmpmisc,1) ? 1 : 2; //Double Magic flag
20322 281 temp_zinit.flags.set(INIT_FL_CANSLASH,get_bit(tmpmisc,2));
20323
20324
4/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 64 times.
537 if(s_version < 15) for(int32_t i=0; i<4; i++)
20325
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&sword_hearts[i],f))
20326 64 return qe_invalid;
20327
20328
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.last_map,f))
20329 {
20330 return qe_invalid;
20331 }
20332
20333
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.last_screen,f))
20334 {
20335 return qe_invalid;
20336 }
20337
20338
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version < 14)
20339 {
20340 byte tempmp;
20341
20342
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
20343 {
20344 return qe_invalid;
20345 }
20346
20347 64 temp_zinit.mcounter[crMAGIC]=tempmp;
20348
20349
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
20350 {
20351 return qe_invalid;
20352 }
20353
20354 64 temp_zinit.counter[crMAGIC]=tempmp;
20355 64 }
20356 else
20357 {
20358
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.mcounter[crMAGIC],f))
20359 {
20360 return qe_invalid;
20361 }
20362
20363
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.counter[crMAGIC],f))
20364 {
20365 return qe_invalid;
20366 }
20367 }
20368
20369
20370
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version < 15)
20371 {
20372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(s_version < 12)
20373 {
20374 64 temp_zinit.mcounter[crMAGIC]*=32;
20375 64 temp_zinit.counter[crMAGIC]*=32;
20376 64 }
20377
20378
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
20379 {
20380
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&beam_hearts[i],f))
20381 {
20382 return qe_invalid;
20383 }
20384 256 }
20385
20386
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&beam_percent,f))
20387 {
20388 return qe_invalid;
20389 }
20390 64 }
20391 else
20392 {
20393
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.bomb_ratio,f))
20394 return qe_invalid;
20395
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(temp_zinit.bomb_ratio < 1)
20396 temp_zinit.bomb_ratio = 1;
20397 217 else bomb_ratio = temp_zinit.bomb_ratio; //jank
20398 }
20399
20400
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version < 15)
20401 {
20402 byte tempbp;
20403
20404
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
20405 {
20406
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
256 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
20407 {
20408 return qe_invalid;
20409 }
20410
20411 256 beam_power[i]=tempbp;
20412 256 }
20413
20414
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&hookshot_links,f))
20415 {
20416 return qe_invalid;
20417 }
20418
20419
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(s_version>6)
20420 {
20421 if(!p_getc(&hookshot_length,f))
20422 {
20423 return qe_invalid;
20424 }
20425
20426 if(!p_getc(&longshot_links,f))
20427 {
20428 return qe_invalid;
20429 }
20430
20431 if(!p_getc(&longshot_length,f))
20432 {
20433 return qe_invalid;
20434 }
20435 }
20436 64 }
20437
20438
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.msg_more_x,f))
20439 {
20440 return qe_invalid;
20441 }
20442
20443
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&temp_zinit.msg_more_y,f))
20444 {
20445 return qe_invalid;
20446 }
20447
20448
1/2
✓ Branch 0 taken 281 times.
✗ Branch 1 not taken.
281 if(!p_getc(&subscr_mode,f))
20449 return qe_invalid;
20450
20451 //old only
20452
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
281 if((Header->zelda_version == 0x192)&&(Header->build<174))
20453 {
20454 byte tmp_boss_key[32];
20455
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 4 times.
132 for(int32_t i=0; i<32; i++)
20456 {
20457
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&tmp_boss_key[i],f))
20458 {
20459 return qe_invalid;
20460 }
20461 128 }
20462
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int q = 0; q < 32*8; ++q)
20463 {
20464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 SETFLAG(temp_zinit.litems[q], (1 << li_boss_key), get_bit(tmp_boss_key, q));
20465 1024 }
20466 4 }
20467
20468
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 4 times.
281 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20469 {
20470
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 217 times.
277 if(s_version <= 10)
20471 {
20472
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&tempbyte,f))
20473 {
20474 return qe_invalid;
20475 }
20476
20477 60 temp_zinit.start_dmap = (word)tempbyte;
20478 60 }
20479 else
20480 {
20481
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.start_dmap,f))
20482 {
20483 return qe_invalid;
20484 }
20485 }
20486
20487
1/2
✓ Branch 0 taken 277 times.
✗ Branch 1 not taken.
277 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20488 {
20489 return qe_invalid;
20490 }
20491 277 }
20492
20493
4/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 200 times.
281 if(s_version>1 && s_version < 29)
20494 {
20495
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&padding,f))
20496 return qe_invalid;
20497 200 temp_zinit.counter[crARROWS] = padding;
20498
20499
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(!p_getc(&padding,f))
20500 return qe_invalid;
20501 200 temp_zinit.mcounter[crARROWS] = padding;
20502 200 }
20503
20504
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>2)
20505 {
20506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 if(s_version <= 10)
20507 {
20508 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20509 {
20510 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20511 {
20512 return qe_invalid;
20513 }
20514 }
20515 }
20516 else
20517 {
20518
2/2
✓ Branch 0 taken 111104 times.
✓ Branch 1 taken 217 times.
111321 for(int32_t i=0; i<MAXLEVELS; i++)
20519 {
20520
1/2
✓ Branch 0 taken 111104 times.
✗ Branch 1 not taken.
111104 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20521 {
20522 return qe_invalid;
20523 }
20524 111104 }
20525 }
20526 217 }
20527
20528
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>3)
20529 {
20530
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_x,f))
20531 {
20532 return qe_invalid;
20533 }
20534
20535
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_y,f))
20536 {
20537 return qe_invalid;
20538 }
20539
20540
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
20541 {
20542 return qe_invalid;
20543 }
20544
20545
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
20546 {
20547 return qe_invalid;
20548 }
20549
20550
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20551 {
20552 return qe_invalid;
20553 }
20554
20555
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20556 {
20557 return qe_invalid;
20558 }
20559
20560
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20561 {
20562 return qe_invalid;
20563 }
20564
20565
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.ss_flags,f))
20566 {
20567 return qe_invalid;
20568 }
20569
20570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217 times.
217 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20572 217 }
20573
20574
3/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
281 if(s_version>4 && s_version<15)
20575 {
20576 if(!p_getc(&moving_fairy_hearts,f))
20577 {
20578 return qe_invalid;
20579 }
20580
20581 if(!p_getc(&moving_fairy_heart_percent,f))
20582 {
20583 return qe_invalid;
20584 }
20585 }
20586
20587
3/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
281 if(s_version>5 && s_version < 10)
20588 {
20589 if(!p_getc(&temp,f))
20590 {
20591 return qe_invalid;
20592 }
20593
20594 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20595 }
20596
20597
3/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 217 times.
✗ Branch 3 not taken.
281 if(s_version>6 && s_version<15)
20598 {
20599 if(!p_getc(&stationary_fairy_hearts,f))
20600 {
20601 return qe_invalid;
20602 }
20603
20604 if(!p_getc(&stationary_fairy_heart_percent,f))
20605 {
20606 return qe_invalid;
20607 }
20608
20609 if(!p_getc(&moving_fairy_magic,f))
20610 {
20611 return qe_invalid;
20612 }
20613
20614 if(!p_getc(&moving_fairy_magic_percent,f))
20615 {
20616 return qe_invalid;
20617 }
20618
20619 if(!p_getc(&stationary_fairy_magic,f))
20620 {
20621 return qe_invalid;
20622 }
20623
20624 if(!p_getc(&stationary_fairy_magic_percent,f))
20625 {
20626 return qe_invalid;
20627 }
20628
20629 if(!p_getc(&blue_potion_hearts,f))
20630 {
20631 return qe_invalid;
20632 }
20633
20634 if(!p_getc(&blue_potion_heart_percent,f))
20635 {
20636 return qe_invalid;
20637 }
20638
20639 if(!p_getc(&red_potion_hearts,f))
20640 {
20641 return qe_invalid;
20642 }
20643
20644 if(!p_getc(&red_potion_heart_percent,f))
20645 {
20646 return qe_invalid;
20647 }
20648
20649 if(!p_getc(&blue_potion_magic,f))
20650 {
20651 return qe_invalid;
20652 }
20653
20654 if(!p_getc(&blue_potion_magic_percent,f))
20655 {
20656 return qe_invalid;
20657 }
20658
20659 if(!p_getc(&red_potion_magic,f))
20660 {
20661 return qe_invalid;
20662 }
20663
20664 if(!p_getc(&red_potion_magic_percent,f))
20665 {
20666 return qe_invalid;
20667 }
20668 }
20669
20670
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>6)
20671
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&padding,f))
20672 return qe_invalid;
20673
20674
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>7)
20675 {
20676
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&padding,f))
20677 {
20678 return qe_invalid;
20679 }
20680 217 }
20681
20682
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>8)
20683 {
20684
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.mcounter[crMONEY],f))
20685 {
20686 return qe_invalid;
20687 }
20688
20689
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.mcounter[crKEYS],f))
20690 {
20691 return qe_invalid;
20692 }
20693 217 }
20694
20695
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 64 times.
281 if(s_version>16)
20696 {
20697
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&tempbyte,f))
20698 {
20699 return qe_invalid;
20700 }
20701 217 temp_zinit.gravity = tempbyte*100;
20702
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_igetw(&temp_zinit.terminalv,f))
20703 {
20704 return qe_invalid;
20705 }
20706
20707
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.msg_speed,f))
20708 {
20709 return qe_invalid;
20710 }
20711
20712
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&padding,f))
20713 {
20714 return qe_invalid;
20715 }
20716
20717
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20718 {
20719 return qe_invalid;
20720 }
20721 217 }
20722
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 12 times.
64 else if (replay_version_check(0, 13))
20723 12 temp_zinit.msg_speed = 0;
20724
20725
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 217 times.
281 if(s_version>17)
20726 {
20727
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20728 {
20729 return qe_invalid;
20730 }
20731 217 }
20732
20733 //expaned init data for larger values in 2.55
20734
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 17 times.
281 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20735 {
20736
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crBOMBS],f))
20737 {
20738 return qe_invalid;
20739 }
20740
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crSBOMBS],f))
20741 {
20742 return qe_invalid;
20743 }
20744
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crBOMBS],f))
20745 {
20746 return qe_invalid;
20747 }
20748
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crSBOMBS],f))
20749 {
20750 return qe_invalid;
20751 }
20752
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.counter[crARROWS],f))
20753 {
20754 return qe_invalid;
20755 }
20756
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.mcounter[crARROWS],f))
20757 {
20758 return qe_invalid;
20759 }
20760
20761 17 }
20762
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if ( s_version >= 20 )
20763 {
20764
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroStep,f))
20765 {
20766 return qe_invalid;
20767 }
20768 17 }
20769 else
20770 {
20771 264 temp_zinit.heroStep = 150; //1.5 pixels per frame
20772 }
20773
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 264 times.
281 if ( s_version >= 21 )
20774 {
20775
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20776 {
20777 return qe_invalid;
20778 }
20779 17 }
20780 else
20781 {
20782 264 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20783 }
20784 //old only
20785
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
281 if((Header->zelda_version == 0x192)&&(Header->build<174))
20786 {
20787 byte items2;
20788
20789
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&items2,f))
20790 {
20791 return qe_invalid;
20792 }
20793
20794 4 temp_zinit.set_item(iDivineFire, get_bit(&items2, idI_DFIRE)!=0);
20795 4 temp_zinit.set_item(iDivineEscape, get_bit(&items2, idI_FWIND)!=0);
20796 4 temp_zinit.set_item(iDivineProtection, get_bit(&items2, idI_NLOVE)!=0);
20797 4 }
20798
20799
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 5 times.
281 if(Header->zelda_version < 0x193)
20800 {
20801
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 5 times.
485 for(int32_t q=0; q<96; q++)
20802 {
20803
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!p_getc(&padding,f))
20804 {
20805 return qe_invalid;
20806 }
20807 480 }
20808
20809 //new only
20810
3/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
20811 {
20812
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20813 {
20814 return qe_invalid;
20815 }
20816
20817
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20818 {
20819 return qe_invalid;
20820 }
20821 1 }
20822 5 }
20823 281 }
20824
20825
3/6
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 217 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
299 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20826 {
20827 //temp_zinit.shield=i_smallshield;
20828 82 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20829
20830
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(sshieldid != -1)
20831 82 temp_zinit.set_item(sshieldid, true);
20832 82 }
20833
20834
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20835 {
20836 18 temp_zinit.mcounter[crLIFE]=3;
20837 18 temp_zinit.counter[crLIFE]=3;
20838 18 temp_zinit.cont_heart=3;
20839 18 temp_zinit.mcounter[crBOMBS]=8;
20840 18 }
20841
20842
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20843 {
20844 18 sword_hearts[0]=0;
20845 18 sword_hearts[1]=5;
20846 18 sword_hearts[2]=12;
20847 18 sword_hearts[3]=21;
20848 18 }
20849
20850
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20851 {
20852 18 temp_zinit.last_map=0;
20853 18 temp_zinit.last_screen=0;
20854 18 }
20855
20856
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20857 {
20858 18 temp_zinit.mcounter[crMAGIC]=0;
20859 18 temp_zinit.counter[crMAGIC]=0;
20860 18 temp_zinit.magicdrainrate = 2;
20861 18 }
20862
20863
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20864 {
20865
20866
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20867 {
20868 72 beam_hearts[x]=100;
20869 72 }
20870
20871
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t i=0; i<idBP_MAX; i++)
20872 {
20873 72 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20874 72 set_qr(qr_LENSHINTS+i,0);
20875 72 }
20876
20877
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20878 {
20879 72 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20880 72 }
20881
20882 18 set_qr(qr_HIDECARRIEDITEMS,0);
20883 18 hookshot_links=100;
20884 18 temp_zinit.msg_more_x=224;
20885 18 temp_zinit.msg_more_y=64;
20886 18 }
20887
20888 // Okay, let's put these legacy values into itemsbuf.
20889
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
299 if(s_version < 15)
20890
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
20891 {
20892
11/11
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 20172 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
20992 switch(i)
20893 {
20894 case iFairyStill:
20895 82 itemsbuf[i].misc1 = stationary_fairy_hearts;
20896 82 itemsbuf[i].misc2 = stationary_fairy_magic;
20897 82 itemsbuf[i].misc3 = 0;
20898
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20899
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20900 82 break;
20901
20902 case iFairyMoving:
20903 82 itemsbuf[i].misc1 = moving_fairy_hearts;
20904 82 itemsbuf[i].misc2 = moving_fairy_magic;
20905 82 itemsbuf[i].misc3 = 50;
20906
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20907
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20908 82 break;
20909
20910 case iRPotion:
20911 82 itemsbuf[i].misc1 = red_potion_hearts;
20912 82 itemsbuf[i].misc2 = red_potion_magic;
20913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20915 82 break;
20916
20917 case iBPotion:
20918 82 itemsbuf[i].misc1 = blue_potion_hearts;
20919 82 itemsbuf[i].misc2 = blue_potion_magic;
20920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20922 82 break;
20923
20924 case iSword:
20925 82 itemsbuf[i].pickup_hearts = sword_hearts[0];
20926 82 itemsbuf[i].misc1 = beam_hearts[0];
20927 82 itemsbuf[i].misc2 = beam_power[0];
20928 // It seems that item_flag1 was already added by reset_itembuf()...
20929 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~item_flag1 : ~item_none;
20930 82 break;
20931
20932 case iWSword:
20933 82 itemsbuf[i].pickup_hearts = sword_hearts[1];
20934 82 itemsbuf[i].misc1 = beam_hearts[1];
20935 82 itemsbuf[i].misc2 = beam_power[1];
20936 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~item_flag1 : ~item_none;
20937 82 break;
20938
20939 case iMSword:
20940 82 itemsbuf[i].pickup_hearts = sword_hearts[2];
20941 82 itemsbuf[i].misc1 = beam_hearts[2];
20942 82 itemsbuf[i].misc2 = beam_power[2];
20943 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~item_flag1 : ~item_none;
20944 82 break;
20945
20946 case iXSword:
20947 82 itemsbuf[i].pickup_hearts = sword_hearts[3];
20948 82 itemsbuf[i].misc1 = beam_hearts[3];
20949 82 itemsbuf[i].misc2 = beam_power[3];
20950 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~item_flag1 : ~item_none;
20951 82 break;
20952
20953 case iHookshot:
20954 82 itemsbuf[i].misc1 = hookshot_length;
20955 82 itemsbuf[i].misc2 = hookshot_links;
20956 82 break;
20957
20958 case iLongshot:
20959 82 itemsbuf[i].misc1 = longshot_length;
20960 82 itemsbuf[i].misc2 = longshot_links;
20961 82 break;
20962 }
20963 21074 }
20964
20965
6/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20966 {
20967 //was new subscreen rule
20968 22 subscr_mode=get_qr(qr_FREEFORM)?1:0;
20969 22 set_qr(qr_FREEFORM,0);
20970 22 }
20971
20972
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20973 {
20974 23 temp_zinit.start_dmap=0;
20975 23 }
20976
20977
5/6
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 276 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
299 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20978 {
20979 23 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20980 23 }
20981
20982
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 217 times.
✓ Branch 2 taken 82 times.
✗ Branch 3 not taken.
299 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20983 {
20984 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20985 temp_zinit.mcounter[crMONEY]=999;
20986 //temp_zinit.counter[crMONEY]=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20987 }
20988
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 6 times.
299 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20989 {
20990 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20991 6 temp_zinit.mcounter[crBOMBS] = 8;
20992 6 }
20993 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20994 //time to ensure that we port all new values properly:
20995
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 82 times.
299 if(Header->zelda_version < 0x250)
20996 {
20997
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 temp_zinit.mcounter[crSBOMBS] = bomb_ratio > 0 ? ( temp_zinit.mcounter[crBOMBS]/temp_zinit.bomb_ratio ) : (temp_zinit.mcounter[crBOMBS]/4);
20998 82 }
20999
21000
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 21)
21001 {
21002
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hp_per_heart,f))
21003 {
21004 return qe_invalid;
21005 }
21006
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magic_per_block,f))
21007 {
21008 return qe_invalid;
21009 }
21010
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
21011 {
21012 return qe_invalid;
21013 }
21014
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
21015 {
21016 return qe_invalid;
21017 }
21018 17 }
21019 else
21020 {
21021 282 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
21022 282 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
21023 282 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
21024 282 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
21025 }
21026
21027
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 17 times.
299 if(s_version > 22)
21028 {
21029
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
21030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.counter[q],f))
21031 return qe_invalid;
21032
2/2
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 17 times.
442 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
21033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if(!p_igetw(&temp_zinit.mcounter[q],f))
21034 return qe_invalid;
21035 17 }
21036
21037
21038
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 23)
21039 {
21040
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_type,f))
21041 {
21042 return qe_invalid;
21043 }
21044
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_arg,f))
21045 {
21046 return qe_invalid;
21047 }
21048
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.dither_percent,f))
21049 {
21050 return qe_invalid;
21051 }
21052
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.def_lightrad,f))
21053 {
21054 return qe_invalid;
21055 }
21056
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.transdark_percent,f))
21057 {
21058 return qe_invalid;
21059 }
21060 17 }
21061 else
21062 {
21063 282 temp_zinit.dither_type = 0;
21064 282 temp_zinit.dither_arg = 0;
21065 282 temp_zinit.dither_percent = 20;
21066 282 temp_zinit.def_lightrad = 24;
21067 282 temp_zinit.transdark_percent = 0;
21068 }
21069
21070
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 24)
21071 {
21072
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.darkcol,f))
21073 {
21074 return qe_invalid;
21075 }
21076 17 }
21077 else
21078 {
21079 282 temp_zinit.darkcol = BLACK;
21080 }
21081
21082
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 17 times.
299 if(s_version > 25)
21083 {
21084
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.gravity,f))
21085 {
21086 return qe_invalid;
21087 }
21088
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.swimgravity,f))
21089 {
21090 return qe_invalid;
21091 }
21092 17 }
21093
21094
21095
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 26)
21096 {
21097
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
21098 {
21099 return qe_invalid;
21100 }
21101
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
21102 {
21103 return qe_invalid;
21104 }
21105
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
21106 {
21107 return qe_invalid;
21108 }
21109 17 }
21110 else
21111 {
21112 282 temp_zinit.heroSideswimUpStep = 150;
21113 282 temp_zinit.heroSideswimSideStep = 100;
21114 282 temp_zinit.heroSideswimDownStep = 75;
21115 }
21116
21117
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 27)
21118 {
21119
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.exitWaterJump,f))
21120 {
21121 return qe_invalid;
21122 }
21123 17 }
21124 else
21125 {
21126 282 temp_zinit.exitWaterJump = 0;
21127 }
21128
21129
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 29)
21130 {
21131
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_igetl(&temp_zinit.bunny_ltm,f))
21132 {
21133 return qe_invalid;
21134 }
21135 17 }
21136 else
21137 {
21138 282 temp_zinit.bunny_ltm = 0;
21139 }
21140
21141
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 282 times.
299 if(s_version > 30)
21142 {
21143
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.switchhookstyle,f))
21144 {
21145 return qe_invalid;
21146 }
21147 17 }
21148 else
21149 {
21150 282 temp_zinit.switchhookstyle = 1;
21151 }
21152
21153
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 17 times.
299 if(s_version > 31)
21154 {
21155
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!p_getc(&temp_zinit.magicdrainrate,f))
21156 {
21157 return qe_invalid;
21158 }
21159 17 }
21160
21161 299 temp_zinit.clear_genscript();
21162
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 12 times.
299 if(s_version > 32)
21163 {
21164 12 word numgenscript = 0;
21165
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&numgenscript,f))
21166 return qe_invalid;
21167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (numgenscript > NUMSCRIPTSGENERIC)
21168 return qe_invalid;
21169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 for(auto q = 1; q < numgenscript; ++q)
21170 {
21171 if(!p_getc(&tempbyte,f))
21172 return qe_invalid;
21173 if(!(tempbyte&2))
21174 continue;
21175 temp_zinit.gen_doscript.set(q, tempbyte&1);
21176 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
21177 return qe_invalid;
21178 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
21179 return qe_invalid;
21180 for(auto p = 0; p < 8; ++p)
21181 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
21182 return qe_invalid;
21183 dword sz;
21184 if(!p_igetl(&sz,f))
21185 return qe_invalid;
21186 temp_zinit.gen_data[q].resize(sz);
21187 std::vector<int32_t> dummy;
21188 if(!p_getlvec(&dummy,f))
21189 return qe_invalid;
21190 temp_zinit.gen_data[q] = dummy;
21191 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
21192 return qe_invalid;
21193 }
21194 12 }
21195
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 6 times.
299 if(s_version > 33)
21196 {
21197
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_mult,f))
21198 return qe_invalid;
21199
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!p_getc(&temp_zinit.hero_swim_div,f))
21200 return qe_invalid;
21201 6 }
21202
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 if(s_version > 34)
21203 {
21204 uint32_t num_used_mapscr_data;
21205 if(!p_igetl(&num_used_mapscr_data,f))
21206 return qe_invalid;
21207 for(uint32_t q = 0; q < num_used_mapscr_data; ++q)
21208 {
21209 uint32_t sz;
21210 if(!p_igetl(&sz,f))
21211 return qe_invalid;
21212 temp_zinit.screen_data[q].resize(sz);
21213 if(sz)
21214 {
21215 std::vector<int32_t> dummy;
21216 if(!p_getlvec(&dummy,f))
21217 return qe_invalid;
21218 temp_zinit.screen_data[q] = dummy;
21219 }
21220 }
21221 }
21222
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 if (s_version > 35)
21223 if(!p_igetzf(&temp_zinit.shove_offset,f))
21224 return qe_invalid;
21225
21226 299 temp_zinit.counter[crLIFE] *= temp_zinit.hp_per_heart;
21227 299 temp_zinit.mcounter[crLIFE] *= temp_zinit.hp_per_heart;
21228
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 110 times.
299 if(!temp_zinit.flags.get(INIT_FL_CONTPERCENT))
21229 110 temp_zinit.cont_heart *= temp_zinit.hp_per_heart;
21230
21231 299 return 0;
21232 299 }
21233 490 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
21234 {
21235 490 zinitdata temp_zinit = {};
21236
21237
3/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
490 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
21238
21239 int32_t dummy;
21240 490 word s_version=0;
21241 byte padding;
21242
21243
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 23 times.
490 if(Header->zelda_version > 0x192)
21244 {
21245
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
467 if(!p_igetw(&s_version,f))
21246 return qe_invalid;
21247
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 if (s_version > V_INITDATA)
21248 return qe_version;
21249 467 FFCore.quest_format[vInitData] = s_version;
21250
21251
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 467 times.
467 if(!read_deprecated_section_cversion(f))
21252 return qe_invalid;
21253
21254 //section size
21255
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
467 if(!p_igetl(&dummy,f))
21256 return qe_invalid;
21257 467 }
21258
21259
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 191 times.
490 if(s_version < 37)
21260 {
21261
2/4
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
299 if(auto ret = readinitdata_old(f,Header,s_version,temp_zinit))
21262 return ret;
21263 299 }
21264 else
21265 {
21266 191 subscr_mode = ssdtMAX;
21267
2/2
✓ Branch 0 taken 6112 times.
✓ Branch 1 taken 191 times.
6303 for(int q = 0; q < MAXITEMS/8; ++q)
21268
2/4
✓ Branch 0 taken 6112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6112 times.
6112 if(!p_getc(&temp_zinit.items[q], f))
21269 return qe_invalid;
21270
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 28 times.
191 if(s_version >= 42)
21271 {
21272
2/2
✓ Branch 0 taken 83456 times.
✓ Branch 1 taken 163 times.
83619 for(int q = 0; q < MAXLEVELS; ++q)
21273 {
21274
2/2
✓ Branch 0 taken 8704 times.
✓ Branch 1 taken 74752 times.
83456 if (s_version >= 44)
21275 {
21276
2/4
✓ Branch 0 taken 74752 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 74752 times.
74752 if(!p_igetw(&temp_zinit.litems[q], f))
21277 return qe_invalid;
21278 74752 }
21279 else
21280 {
21281
2/4
✓ Branch 0 taken 8704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8704 times.
8704 if(!p_getc(&padding, f))
21282 return qe_invalid;
21283 8704 temp_zinit.litems[q] = word(padding);
21284 }
21285 83456 }
21286 163 }
21287 else
21288 {
21289 byte tmp_map[MAXLEVELS/8];
21290 byte tmp_compass[MAXLEVELS/8];
21291 byte tmp_boss_key[MAXLEVELS/8];
21292 byte tmp_mcguffin[MAXLEVELS/8];
21293
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 28 times.
1820 for(int q = 0; q < MAXLEVELS/8; ++q)
21294 {
21295
2/4
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1792 times.
✗ Branch 3 not taken.
1792 if(!p_getc(&tmp_map[q], f))
21296 return qe_invalid;
21297
2/4
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1792 times.
1792 if(!p_getc(&tmp_compass[q], f))
21298 return qe_invalid;
21299
2/4
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1792 times.
1792 if(!p_getc(&tmp_boss_key[q], f))
21300 return qe_invalid;
21301
2/4
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1792 times.
✗ Branch 3 not taken.
1792 if(!p_getc(&tmp_mcguffin[q], f))
21302 return qe_invalid;
21303 1792 }
21304
2/2
✓ Branch 0 taken 14336 times.
✓ Branch 1 taken 28 times.
14364 for(int q = 0; q < MAXLEVELS; ++q)
21305 {
21306
2/4
✓ Branch 0 taken 14336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14336 times.
✗ Branch 3 not taken.
14336 SETFLAG(temp_zinit.litems[q], (1 << li_map), get_bit(tmp_map, q));
21307
3/4
✓ Branch 0 taken 14336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 14316 times.
14336 SETFLAG(temp_zinit.litems[q], (1 << li_compass), get_bit(tmp_compass, q));
21308
2/4
✓ Branch 0 taken 14336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14336 times.
14336 SETFLAG(temp_zinit.litems[q], (1 << li_boss_key), get_bit(tmp_boss_key, q));
21309
2/4
✓ Branch 0 taken 14336 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14336 times.
✗ Branch 3 not taken.
14336 SETFLAG(temp_zinit.litems[q], (1 << li_mcguffin), get_bit(tmp_mcguffin, q));
21310 14336 }
21311 }
21312
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getbvec(&temp_zinit.level_keys, f))
21313 return qe_invalid;
21314 byte num_counters;
21315
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&num_counters,f))
21316 return qe_invalid;
21317
2/2
✓ Branch 0 taken 20437 times.
✓ Branch 1 taken 191 times.
20628 for(int q = 0; q < num_counters; ++q)
21318
2/4
✓ Branch 0 taken 20437 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20437 times.
20437 if(!p_igetw(&temp_zinit.counter[q],f))
21319 return qe_invalid;
21320
2/2
✓ Branch 0 taken 191 times.
✓ Branch 1 taken 20437 times.
20628 for(int q = 0; q < num_counters; ++q)
21321
2/4
✓ Branch 0 taken 20437 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20437 times.
20437 if(!p_igetw(&temp_zinit.mcounter[q],f))
21322 return qe_invalid;
21323
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.bomb_ratio,f))
21324 return qe_invalid;
21325
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.hcp,f))
21326 return qe_invalid;
21327
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.hcp_per_hc,f))
21328 return qe_invalid;
21329
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 191 times.
191 if(!p_igetw(&temp_zinit.cont_heart,f))
21330 return qe_invalid;
21331
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.hp_per_heart,f))
21332 return qe_invalid;
21333
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 191 times.
191 if(!p_getc(&temp_zinit.magic_per_block,f))
21334 return qe_invalid;
21335
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
21336 return qe_invalid;
21337
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
21338 return qe_invalid;
21339
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.dither_type,f))
21340 return qe_invalid;
21341
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.dither_arg,f))
21342 return qe_invalid;
21343
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 191 times.
191 if(!p_getc(&temp_zinit.dither_percent,f))
21344 return qe_invalid;
21345
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.def_lightrad,f))
21346 return qe_invalid;
21347
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.transdark_percent,f))
21348 return qe_invalid;
21349
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.darkcol,f))
21350 return qe_invalid;
21351
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_igetl(&temp_zinit.ss_grid_x,f))
21352 return qe_invalid;
21353
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_igetl(&temp_zinit.ss_grid_y,f))
21354 return qe_invalid;
21355
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_igetl(&temp_zinit.ss_grid_xofs,f))
21356 return qe_invalid;
21357
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_igetl(&temp_zinit.ss_grid_yofs,f))
21358 return qe_invalid;
21359
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_igetl(&temp_zinit.ss_grid_color,f))
21360 return qe_invalid;
21361
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 191 times.
191 if(!p_igetl(&temp_zinit.ss_bbox_1_color,f))
21362 return qe_invalid;
21363
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_igetl(&temp_zinit.ss_bbox_2_color,f))
21364 return qe_invalid;
21365
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_igetl(&temp_zinit.ss_flags,f))
21366 return qe_invalid;
21367
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getbitstr(&temp_zinit.flags,f))
21368 return qe_invalid;
21369
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 191 times.
191 if(!p_getc(&temp_zinit.last_map,f))
21370 return qe_invalid;
21371
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.last_screen,f))
21372 return qe_invalid;
21373
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.msg_more_x,f))
21374 return qe_invalid;
21375
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.msg_more_y,f))
21376 return qe_invalid;
21377
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
21378 return qe_invalid;
21379
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.msg_speed,f))
21380 return qe_invalid;
21381
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_igetl(&temp_zinit.gravity,f))
21382 return qe_invalid;
21383
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_igetl(&temp_zinit.swimgravity,f))
21384 return qe_invalid;
21385
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_igetw(&temp_zinit.terminalv,f))
21386 return qe_invalid;
21387
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.hero_swim_speed,f))
21388 return qe_invalid;
21389
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.hero_swim_mult,f))
21390 return qe_invalid;
21391
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.hero_swim_div,f))
21392 return qe_invalid;
21393
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
21394 return qe_invalid;
21395
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
21396 return qe_invalid;
21397
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
21398 return qe_invalid;
21399
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_igetl(&temp_zinit.exitWaterJump,f))
21400 return qe_invalid;
21401
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_igetw(&temp_zinit.heroStep,f))
21402 return qe_invalid;
21403
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
21404 return qe_invalid;
21405
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
21406 return qe_invalid;
21407
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_igetl(&temp_zinit.bunny_ltm,f))
21408 return qe_invalid;
21409
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_igetw(&temp_zinit.start_dmap,f))
21410 return qe_invalid;
21411
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_igetw(&temp_zinit.subscrSpeed,f))
21412 return qe_invalid;
21413
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.switchhookstyle,f))
21414 return qe_invalid;
21415
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getc(&temp_zinit.magicdrainrate,f))
21416 return qe_invalid;
21417
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_igetzf(&temp_zinit.shove_offset,f))
21418 return qe_invalid;
21419
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getbitstr(&temp_zinit.gen_doscript, f))
21420 return qe_invalid;
21421
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getbmap(&temp_zinit.gen_exitState, f))
21422 return qe_invalid;
21423
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 191 times.
191 if(!p_getbmap(&temp_zinit.gen_reloadState, f))
21424 return qe_invalid;
21425
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 191 times.
191 if(!p_getbmap(&temp_zinit.gen_initd, f))
21426 return qe_invalid;
21427
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getbmap(&temp_zinit.gen_eventstate, f))
21428 return qe_invalid;
21429
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getbmap(&temp_zinit.gen_data, f))
21430 return qe_invalid;
21431
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if(!p_getbmap(&temp_zinit.screen_data, f))
21432 return qe_invalid;
21433
1/2
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
191 if (s_version >= 38)
21434 {
21435
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if (!p_getc(&temp_zinit.spriteflickerspeed, f))
21436 return qe_invalid;
21437
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if (!p_getc(&temp_zinit.spriteflickercolor, f))
21438 return qe_invalid;
21439
2/4
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 191 times.
✗ Branch 3 not taken.
191 if (!p_getc(&temp_zinit.spriteflickertransp, f))
21440 return qe_invalid;
21441 191 }
21442
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 28 times.
191 if(s_version >= 39)
21443
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetzf(&temp_zinit.air_drag, f))
21444 return qe_invalid;
21445
21446 // TODO: this first branch can likely be removed, as it only fixes an issues
21447 // that existed for a handful of temporary z3 builds (and active users of that
21448 // fork would have been updating often, beyond s_version 40).
21449
3/4
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 163 times.
191 if (Header->is_z3 && s_version == 40)
21450 {
21451 if(!p_getc(&temp_zinit.region_mapping, f))
21452 return qe_invalid;
21453 }
21454 else
21455 {
21456
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 28 times.
191 if(s_version >= 40)
21457 {
21458
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetw(&temp_zinit.light_wave_rate, f))
21459 return qe_invalid;
21460
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_igetw(&temp_zinit.light_wave_size, f))
21461 return qe_invalid;
21462 163 }
21463
21464
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 28 times.
191 if(s_version >= 41)
21465 {
21466
2/4
✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
163 if(!p_getc(&temp_zinit.region_mapping, f))
21467 return qe_invalid;
21468 163 }
21469 }
21470
21471
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 157 times.
191 if(s_version >= 43)
21472
2/2
✓ Branch 0 taken 40192 times.
✓ Branch 1 taken 157 times.
40349 for(uint q = 0; q < NUM_BOTTLE_SLOTS; ++q)
21473
2/4
✓ Branch 0 taken 40192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40192 times.
✗ Branch 3 not taken.
40192 if (!p_getc(&temp_zinit.bottle_slot[q], f))
21474 157 return qe_invalid;
21475
21476
2/2
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 45 times.
191 if(s_version >= 44)
21477
2/4
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
146 if (!p_getbvec(&temp_zinit.lvlswitches, f))
21478 return qe_invalid;
21479
21480
2/2
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 45 times.
191 if (s_version >= 45)
21481 {
21482
2/4
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
146 if (!p_igetw(&temp_zinit.item_spawn_flicker, f))
21483 return qe_invalid;
21484
2/4
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
146 if (!p_igetw(&temp_zinit.item_timeout_dur, f))
21485 return qe_invalid;
21486
2/4
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
146 if (!p_igetw(&temp_zinit.item_timeout_flicker, f))
21487 return qe_invalid;
21488
2/4
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
146 if (!p_getc(&temp_zinit.item_flicker_speed, f))
21489 return qe_invalid;
21490 146 }
21491
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 146 times.
191 if(s_version >= 46)
21492 {
21493
2/2
✓ Branch 0 taken 730 times.
✓ Branch 1 taken 146 times.
876 for(int q = 0; q < SPRITE_THRESHOLD_MAX; ++q)
21494
2/4
✓ Branch 0 taken 730 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 730 times.
✗ Branch 3 not taken.
730 if(!p_igetw(&temp_zinit.sprite_z_thresholds[q], f))
21495 return qe_invalid;
21496 146 }
21497 }
21498
21499
2/2
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 344 times.
490 if(s_version < 46)
21500 {
21501 344 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_GROUND] = temp_zinit.jump_hero_layer_threshold;
21502 344 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_3] = temp_zinit.jump_hero_layer_threshold;
21503 344 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_4] = temp_zinit.jump_hero_layer_threshold;
21504 344 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_OVERHEAD] = word(-1);
21505 344 temp_zinit.sprite_z_thresholds[SPRITE_THRESHOLD_5] = word(-1);
21506 344 }
21507
21508
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 if (should_skip)
21509 return 0;
21510
21511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 490 times.
490 if(loading_tileset_flags & TILESET_CLEARMAPS)
21512 {
21513 temp_zinit.last_map = 0;
21514 temp_zinit.last_screen = 0;
21515 temp_zinit.screen_data.clear();
21516 }
21517
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 temp_zinit.normalize();
21518
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 zinit = temp_zinit;
21519
21520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 490 times.
490 if(zinit.heroAnimationStyle==las_zelda3slow)
21521 {
21522 hero_animation_speed=2;
21523 }
21524 else
21525 {
21526 490 hero_animation_speed=1;
21527 }
21528
21529 490 return 0;
21530 490 }
21531
21532 /*
21533 void setupitemdropsets()
21534 {
21535 for(int32_t i=0; i<isMAX; i++)
21536 {
21537 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21538 }
21539 }
21540 */
21541
21542 431 int32_t readitemdropsets(PACKFILE *f, int32_t version)
21543 {
21544
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 23 times.
431 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_itemdropsets);
21545
21546 dword dummy_dword;
21547 431 word item_drop_sets_to_read=0;
21548 item_drop_object tempitemdrop;
21549 431 word s_version=0;
21550
21551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431 times.
431 if (!should_skip)
21552
2/2
✓ Branch 0 taken 110336 times.
✓ Branch 1 taken 431 times.
110767 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21553 {
21554 110336 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21555 110767 }
21556
21557
2/2
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 23 times.
431 if(version > 0x192)
21558 {
21559 408 item_drop_sets_to_read=0;
21560
21561 //section version info
21562
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_igetw(&s_version,f))
21563 {
21564 return qe_invalid;
21565 }
21566
21567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if (s_version > V_ITEMDROPSETS)
21568 return qe_version;
21569
21570 408 FFCore.quest_format[vItemDropsets] = s_version;
21571
21572
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!read_deprecated_section_cversion(f))
21573 {
21574 return qe_invalid;
21575 }
21576
21577 //section size
21578
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_igetl(&dummy_dword,f))
21579 {
21580 return qe_invalid;
21581 }
21582
21583 //finally... section data
21584
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_igetw(&item_drop_sets_to_read,f))
21585 {
21586 return qe_invalid;
21587 }
21588
21589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if (item_drop_sets_to_read > MAXITEMDROPSETS)
21590 {
21591 return qe_invalid;
21592 }
21593 408 }
21594 else
21595 {
21596 23 init_item_drop_sets();
21597 }
21598
21599
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 408 times.
431 if(s_version>=1)
21600 {
21601
2/2
✓ Branch 0 taken 6296 times.
✓ Branch 1 taken 408 times.
6704 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21602 {
21603
1/2
✓ Branch 0 taken 6296 times.
✗ Branch 1 not taken.
6296 if(!p_getstr(tempitemdrop.name,sizeof(tempitemdrop.name)-1,f))
21604 {
21605 return qe_invalid;
21606 }
21607
21608
2/2
✓ Branch 0 taken 62960 times.
✓ Branch 1 taken 6296 times.
69256 for(int32_t j=0; j<10; ++j)
21609 {
21610
1/2
✓ Branch 0 taken 62960 times.
✗ Branch 1 not taken.
62960 if(!p_igetw(&tempitemdrop.item[j],f))
21611 {
21612 return qe_invalid;
21613 }
21614 62960 }
21615
21616
2/2
✓ Branch 0 taken 69256 times.
✓ Branch 1 taken 6296 times.
75552 for(int32_t j=0; j<11; ++j)
21617 {
21618
1/2
✓ Branch 0 taken 69256 times.
✗ Branch 1 not taken.
69256 if(!p_igetw(&tempitemdrop.chance[j],f))
21619 {
21620 return qe_invalid;
21621 }
21622 69256 }
21623
21624 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21625 // overrides the quest's set #12.
21626
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6296 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6296 if(s_version<2 && i==12)
21627 continue;
21628
21629 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21630
1/4
✓ Branch 0 taken 6296 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6296 if(s_version<2) for(int32_t j=0; j<10; ++j)
21631 {
21632 int32_t it = tempitemdrop.item[j];
21633
21634 if((itemsbuf[it].type == itype_rupee
21635 && ((itemsbuf[it].amount)&0xFFF) == 10)
21636 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21637 {
21638 tempitemdrop.chance[j+1]=0;
21639 }
21640 else if(itemsbuf[it].type == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21641 {
21642 tempitemdrop.chance[j+1]=0;
21643 }
21644
21645 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21646 if(itemsbuf[it].type == itype_misc)
21647 {
21648 // If a non-gameplay item was selected, then item drop was aborted.
21649 // Reflect this by increasing the 'Nothing' chance accordingly.
21650 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21651 tempitemdrop.chance[j+1]=0;
21652 }
21653 }
21654
21655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6296 times.
6296 if (!should_skip)
21656 6296 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21657 6296 }
21658 408 }
21659
21660 431 return 0;
21661 431 }
21662
21663 408 int32_t readfavorites(PACKFILE *f, int32_t)
21664 {
21665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_favorites);
21666
21667 int32_t temp_num;
21668 dword dummy_dword;
21669 word num_favorite_combos;
21670 word num_favorite_combo_aliases;
21671 408 word s_version=0;
21672
21673 //section version info
21674
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_igetw(&s_version,f))
21675 {
21676 return qe_invalid;
21677 }
21678
21679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if (s_version > V_FAVORITES)
21680 return qe_version;
21681
21682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if (!should_skip)
21683 408 FFCore.quest_format[vFavourites] = s_version;
21684
21685
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!read_deprecated_section_cversion(f))
21686 {
21687 return qe_invalid;
21688 }
21689
21690 //section size
21691
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_igetl(&dummy_dword,f))
21692 {
21693 return qe_invalid;
21694 }
21695
21696 408 word per_row = FAVORITECOMBO_PER_ROW;
21697 408 word per_page = FAVORITECOMBO_PER_PAGE;
21698
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 197 times.
408 if(s_version >= 3)
21699
1/2
✓ Branch 0 taken 197 times.
✗ Branch 1 not taken.
197 if(!p_igetw(&per_row,f))
21700 return qe_invalid;
21701
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 191 times.
408 if(s_version >= 4)
21702
1/2
✓ Branch 0 taken 191 times.
✗ Branch 1 not taken.
191 if(!p_igetw(&per_page,f))
21703 return qe_invalid;
21704 //finally... section data
21705
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 if(!p_igetw(&num_favorite_combos,f))
21706 {
21707 return qe_invalid;
21708 }
21709
21710 //Hack; port old favorite combos
21711
3/4
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 197 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 211 times.
408 if(s_version < 3 && num_favorite_combos == 100)
21712 211 per_row = 13;
21713
21714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if (!should_skip)
21715
2/2
✓ Branch 0 taken 514080 times.
✓ Branch 1 taken 408 times.
514488 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21716 514488 favorite_combos[q] = -1;
21717 408 byte favtype = 0;
21718
2/2
✓ Branch 0 taken 28015 times.
✓ Branch 1 taken 408 times.
28423 for(int32_t i=0; i<num_favorite_combos; i++)
21719 {
21720
2/2
✓ Branch 0 taken 6909 times.
✓ Branch 1 taken 21106 times.
28015 if (s_version >= 4)
21721 {
21722
1/2
✓ Branch 0 taken 6909 times.
✗ Branch 1 not taken.
6909 if (!p_getc(&favtype, f))
21723 {
21724 return qe_invalid;
21725 }
21726 6909 }
21727 else
21728 21106 favtype = 0;
21729
1/2
✓ Branch 0 taken 28015 times.
✗ Branch 1 not taken.
28015 if(!p_igetl(&temp_num,f))
21730 {
21731 return qe_invalid;
21732 }
21733
21734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28015 times.
28015 if (should_skip)
21735 continue;
21736
21737
2/2
✓ Branch 0 taken 6909 times.
✓ Branch 1 taken 21106 times.
28015 if(per_row == FAVORITECOMBO_PER_ROW)
21738 {
21739 6909 favorite_combos[i] = temp_num;
21740 6909 favorite_combo_modes[i] = favtype;
21741 6909 }
21742 else
21743 {
21744 21106 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21745 21106 favorite_combos[new_i]=temp_num;
21746 21106 favorite_combo_modes[new_i] = favtype;
21747 }
21748 28015 }
21749
21750 // Discard the separate favorite aliases list from previous versions
21751
2/2
✓ Branch 0 taken 191 times.
✓ Branch 1 taken 217 times.
408 if(s_version<4)
21752 {
21753
1/2
✓ Branch 0 taken 217 times.
✗ Branch 1 not taken.
217 if (!p_igetw(&num_favorite_combo_aliases, f))
21754 {
21755 return qe_invalid;
21756 }
21757
21758
2/2
✓ Branch 0 taken 21100 times.
✓ Branch 1 taken 217 times.
21317 for (int32_t i = 0; i < num_favorite_combo_aliases; i++)
21759 {
21760
1/2
✓ Branch 0 taken 21100 times.
✗ Branch 1 not taken.
21100 if (!p_igetl(&temp_num, f))
21761 {
21762 return qe_invalid;
21763 }
21764 21100 }
21765 217 }
21766
21767 408 word max_combo_cols = 0;
21768 408 word max_mappages = 0;
21769
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 197 times.
408 if(s_version >= 2)
21770 {
21771
1/2
✓ Branch 0 taken 197 times.
✗ Branch 1 not taken.
197 if(!p_igetw(&max_combo_cols,f))
21772 return qe_invalid;
21773 197 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21774
2/2
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 197 times.
985 for(int q = 0; q < max_combo_cols; ++q)
21775 {
21776
1/2
✓ Branch 0 taken 788 times.
✗ Branch 1 not taken.
788 if(!p_igetl(&tmp,f))
21777 return qe_invalid;
21778
1/2
✓ Branch 0 taken 788 times.
✗ Branch 1 not taken.
788 if(!p_igetl(&tmp2,f))
21779 return qe_invalid;
21780
1/2
✓ Branch 0 taken 788 times.
✗ Branch 1 not taken.
788 if(!p_igetl(&tmp3,f))
21781 return qe_invalid;
21782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 788 times.
788 if(q < MAX_COMBO_COLS)
21783 {
21784 788 First[q] = tmp;
21785 788 combo_alistpos[q] = tmp2;
21786 788 combo_pool_listpos[q] = tmp3;
21787 788 }
21788 788 }
21789
21790
1/2
✓ Branch 0 taken 197 times.
✗ Branch 1 not taken.
197 if(!p_igetw(&max_mappages,f))
21791 return qe_invalid;
21792
2/2
✓ Branch 0 taken 1773 times.
✓ Branch 1 taken 197 times.
1970 for(int q = 0; q < max_mappages; ++q)
21793 {
21794
1/2
✓ Branch 0 taken 1773 times.
✗ Branch 1 not taken.
1773 if(!p_igetl(&tmp,f))
21795 return qe_invalid;
21796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1773 times.
1773 if(!p_igetl(&tmp2,f))
21797 return qe_invalid;
21798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1773 times.
1773 if(q < MAX_MAPPAGE_BTNS)
21799 {
21800 1773 map_page[q].map = tmp;
21801 1773 map_page[q].screen = tmp2;
21802 1773 }
21803 1773 }
21804 197 }
21805
21806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if (should_skip)
21807 return 0;
21808
21809
2/2
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 408 times.
1252 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21810 {
21811 844 First[q] = 0;
21812 844 combo_alistpos[q] = 0;
21813 844 combo_pool_listpos[q] = 0;
21814 844 }
21815
2/2
✓ Branch 0 taken 1899 times.
✓ Branch 1 taken 408 times.
2307 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21816 {
21817 1899 map_page[q].map = 0;
21818 1899 map_page[q].screen = 0;
21819 1899 }
21820
21821 408 return 0;
21822 408 }
21823
21824 /*
21825 switch (ret) {
21826 case 0:
21827 break;
21828
21829 case qe_invalid:
21830 goto invalid;
21831 break;
21832 default:
21833 pack_fclose(f);
21834 if(!oldquest)
21835 delete_file(tmpfilename);
21836 return ret;
21837 break;
21838 }
21839 */
21840
21841 const char *skip_text[skip_max]=
21842 {
21843 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21844 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21845 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21846 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21847 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21848 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21849 "skip_favorites"
21850 };
21851
21852
21853 void port250QuestRules(){
21854
21855 portCandleRules(); //Candle
21856 portBombRules();
21857
21858 }
21859
21860 void portCandleRules()
21861 {
21862 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21863 //itemdata itemsbuf;
21864 for ( int32_t q = 0; q < MAXITEMS; q++ )
21865 {
21866 if ( itemsbuf[q].type == itype_candle )
21867 {
21868 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21869 else itemsbuf[q].flags &= ~ item_flag2;
21870 }
21871 }
21872 }
21873
21874 void portBombRules()
21875 {
21876 bool hurtshero = get_qr(qr_OUCHBOMBS);
21877 //itemdata itemsbuf;
21878 for ( int32_t q = 0; q < MAXITEMS; q++ )
21879 {
21880 if ( itemsbuf[q].type == itype_bomb )
21881 {
21882 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21883 else itemsbuf[q].flags &= ~ item_flag2;
21884 }
21885 }
21886 }
21887
21888 18981 static int section_id_to_enum(int id)
21889 {
21890
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 820 times.
✓ Branch 2 taken 820 times.
✓ Branch 3 taken 820 times.
✓ Branch 4 taken 820 times.
✓ Branch 5 taken 820 times.
✓ Branch 6 taken 737 times.
✓ Branch 7 taken 820 times.
✓ Branch 8 taken 820 times.
✓ Branch 9 taken 820 times.
✓ Branch 10 taken 820 times.
✓ Branch 11 taken 820 times.
✓ Branch 12 taken 820 times.
✓ Branch 13 taken 737 times.
✓ Branch 14 taken 737 times.
✓ Branch 15 taken 820 times.
✓ Branch 16 taken 820 times.
✓ Branch 17 taken 761 times.
✓ Branch 18 taken 737 times.
✓ Branch 19 taken 737 times.
✓ Branch 20 taken 737 times.
✓ Branch 21 taken 820 times.
✓ Branch 22 taken 820 times.
✓ Branch 23 taken 761 times.
✓ Branch 24 taken 737 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
18981 switch (id)
21891 {
21892 case ID_HEADER: return skip_header;
21893 820 case ID_RULES: return skip_rules;
21894 820 case ID_STRINGS: return skip_strings;
21895 820 case ID_MISC: return skip_misc;
21896 820 case ID_TILES: return skip_tiles;
21897 820 case ID_COMBOS: return skip_combos;
21898 737 case ID_COMBOALIASES: return skip_comboaliases;
21899 820 case ID_CSETS: return skip_csets;
21900 820 case ID_MAPS: return skip_maps;
21901 820 case ID_DMAPS: return skip_dmaps;
21902 820 case ID_DOORS: return skip_doors;
21903 820 case ID_ITEMS: return skip_items;
21904 820 case ID_WEAPONS: return skip_weapons;
21905 737 case ID_COLORS: return skip_colors;
21906 737 case ID_ICONS: return skip_icons;
21907 820 case ID_INITDATA: return skip_initdata;
21908 820 case ID_GUYS: return skip_guys;
21909 761 case ID_HEROSPRITES: return skip_herosprites;
21910 737 case ID_SUBSCREEN: return skip_subscreens;
21911 737 case ID_FFSCRIPT: return skip_ffscript;
21912 737 case ID_SFX: return skip_sfx;
21913 820 case ID_MIDIS: return skip_midis;
21914 820 case ID_CHEATS: return skip_cheats;
21915 761 case ID_ITEMDROPSETS: return skip_itemdropsets;
21916 737 case ID_FAVORITES: return skip_favorites;
21917 case ID_ZINFO: return skip_zinfo;
21918 }
21919
21920 return -1;
21921 18981 }
21922
21923 18573 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21924 {
21925 18573 int section_enum = section_id_to_enum(section_id);
21926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18573 times.
18573 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21927
2/2
✓ Branch 0 taken 6909 times.
✓ Branch 1 taken 11664 times.
18573 if (skip)
21928 {
21929 word s_version;
21930
1/2
✓ Branch 0 taken 6909 times.
✗ Branch 1 not taken.
6909 if (!p_igetw(&s_version,f))
21931 {
21932 return qe_invalid;
21933 }
21934
21935
1/2
✓ Branch 0 taken 6909 times.
✗ Branch 1 not taken.
6909 if (!read_deprecated_section_cversion(f))
21936 {
21937 return qe_invalid;
21938 }
21939
21940
3/4
✓ Branch 0 taken 329 times.
✓ Branch 1 taken 6580 times.
✓ Branch 2 taken 329 times.
✗ Branch 3 not taken.
6909 if (section_id == ID_RULES && s_version > 16)
21941 {
21942 dword dummy;
21943 if (!p_igetl(&dummy,f))
21944 {
21945 return qe_invalid;
21946 }
21947 }
21948
21949
3/4
✓ Branch 0 taken 329 times.
✓ Branch 1 taken 6580 times.
✓ Branch 2 taken 329 times.
✗ Branch 3 not taken.
6909 if (section_id == ID_FFSCRIPT && s_version >= 18)
21950 {
21951 word dummy;
21952 if (!p_igetw(&dummy,f))
21953 {
21954 return qe_invalid;
21955 }
21956 }
21957
21958 dword section_length;
21959
1/2
✓ Branch 0 taken 6909 times.
✗ Branch 1 not taken.
6909 if (!p_igetl(&section_length,f))
21960 {
21961 return qe_invalid;
21962 }
21963
21964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6909 times.
6909 if (pack_fseek(f, section_length))
21965 {
21966 return qe_invalid;
21967 }
21968
21969
2/2
✓ Branch 0 taken 329 times.
✓ Branch 1 taken 6580 times.
6909 if (!pack_feof(f))
21970 {
21971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6580 times.
6580 if (!p_mgetl(&section_id,f))
21972 {
21973 return qe_invalid;
21974 }
21975 6580 }
21976
21977 6909 return qe_cancel;
21978 }
21979
21980 11664 return qe_OK;
21981 18573 }
21982
21983 // TODO: this was copied from zc/zasm_utils.cpp
21984 282 static void _zasm_for_every_script(std::function<void(zasm_script*)> fn)
21985 {
21986 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
21987
21988 282 std::vector<zasm_script*> scripts;
21989
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 scripts.reserve(zasm_scripts.size());
21990
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 301585 times.
301867 for (auto& script : zasm_scripts)
21991
2/2
✓ Branch 0 taken 293103 times.
✓ Branch 1 taken 8482 times.
301585 if (script->valid())
21992
1/2
✓ Branch 0 taken 8482 times.
✗ Branch 1 not taken.
8482 scripts.push_back(script.get());
21993
21994
2/4
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 282 times.
✗ Branch 3 not taken.
282 std::for_each(scripts.begin(), scripts.end(), fn);
21995 282 }
21996
21997 490 static bool compat_qr_hide_bottom_pixels(const zquestheader& header)
21998 {
21999 // 2.55.9 or newer?
22000
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 326 times.
490 if (header.compareVer(2, 55, 9) >= 0)
22001 164 return false; // defer to whatever was set
22002
22003 // Replays created in 2.55 for quests prior to 2.55.9 should continue hiding the bottom pixels.
22004
12/18
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 276 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 276 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50 times.
✓ Branch 7 taken 276 times.
✓ Branch 8 taken 50 times.
✓ Branch 9 taken 276 times.
✓ Branch 10 taken 50 times.
✓ Branch 11 taken 276 times.
✓ Branch 12 taken 38 times.
✓ Branch 13 taken 288 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
326 if (replay_is_replaying() && replay_get_meta_str("zc_version_created").starts_with("2.55"))
22005 38 return true;
22006
22007 // Quests prior to 2.55.9 with a scripted subscreen?
22008
2/2
✓ Branch 0 taken 145923 times.
✓ Branch 1 taken 285 times.
146208 for (int i = 0; i < MAXDMAPS; i++)
22009 {
22010 145923 int script = DMaps[i].active_sub_script;
22011
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 145920 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
145923 if (script && dmapscripts[script] && dmapscripts[script]->valid())
22012 3 return true;
22013 145920 }
22014
22015 // Only a couple quests take any time (~7ms) on my intel mac to check all the ZASM... cache those.
22016
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 std::string title = header.title;
22017
3/4
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 282 times.
285 if (title == "Yuurand: Tales of the Labyrinth")
22018 3 return true;
22019
22020 // Look for ZASM setting values of 167, 168, etc. This is a sign that the script may be drawing something
22021 // near the old "bottom" of the screen, or is attempting to fill the entire screen with a draw command.
22022 // In these cases, the compat rule must be flipped on. As of writing, 72 quests in the PZC database match
22023 // this query: https://gist.github.com/connorjclark/edd12f84c9aac0c924ed328d3f8efcfa
22024 282 bool found = false;
22025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
8764 _zasm_for_every_script([&](auto script){
22026
2/2
✓ Branch 0 taken 3033 times.
✓ Branch 1 taken 5449 times.
8482 if (found) return;
22027
22028
2/2
✓ Branch 0 taken 5419 times.
✓ Branch 1 taken 23840130 times.
23845549 for (const auto& instr : script->zasm)
22029 {
22030
4/4
✓ Branch 0 taken 20882211 times.
✓ Branch 1 taken 2957919 times.
✓ Branch 2 taken 358211 times.
✓ Branch 3 taken 20524000 times.
23840130 if (!(instr.command == SETV || instr.command == PUSHV)) continue;
22031
22032 3316130 int value = instr.arg2;
22033
9/10
✓ Branch 0 taken 3316128 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3316125 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3316101 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 3316101 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 3316100 times.
3316130 if (value == 167000000 || value == 168000000 || value == 167870000 || value == 167910000 || value == 168130000)
22034 {
22035 30 found = true;
22036 30 break;
22037 }
22038 }
22039 8482 });
22040
22041 282 return found;
22042 490 }
22043
22044 static int32_t prev_quest_format[versiontypesLAST];
22045 static byte prev_quest_rules[QUESTRULES_NEW_SIZE];
22046 static byte prev_extra_rules[EXTRARULES_SIZE];
22047 static byte prev_midi_flags[MIDIFLAGS_SIZE];
22048 static word prev_map_count;
22049
22050 // When skipping any section, we are loading a qst file just to poke at a couple things.
22051 // We should not mutate important globals in that case.
22052 // We should also restore these globals when loading a qst fails.
22053 // Globals that are read by usecases of `skip_flags` will have to be restored manually by the caller
22054 // (see load_imagebuf).
22055 820 static void store_prev_qstload_global_state()
22056 {
22057 820 memcpy(prev_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
22058 820 memcpy(prev_extra_rules, extra_rules, EXTRARULES_SIZE);
22059 820 memcpy(prev_midi_flags, midi_flags, MIDIFLAGS_SIZE);
22060 820 memcpy(prev_quest_format, FFCore.quest_format, versiontypesLAST);
22061 820 prev_map_count = map_count;
22062 820 }
22063
22064 330 static void restore_prev_qstload_global_state()
22065 {
22066 330 memcpy(quest_rules, prev_quest_rules, QUESTRULES_NEW_SIZE);
22067 330 memcpy(extra_rules, prev_extra_rules, EXTRARULES_SIZE);
22068 330 unpack_qrs();
22069 330 memcpy(midi_flags, prev_midi_flags, MIDIFLAGS_SIZE);
22070 330 memcpy(FFCore.quest_format, prev_quest_format, versiontypesLAST);
22071 330 map_count = prev_map_count;
22072 330 }
22073
22074 //Internal function for loadquest wrapper
22075 // TODO: refactor to never mutate global state, to make loading partial qst files easier and less error prone. huge project.
22076 820 static int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata)
22077 {
22078 820 DMapEditorLastMaptileUsed = 0;
22079 820 combosread=false;
22080 820 mapsread=false;
22081 820 fixffcs=false;
22082
22083 820 store_prev_qstload_global_state();
22084
22085 820 bool skipping_any = false;
22086
2/2
✓ Branch 0 taken 3280 times.
✓ Branch 1 taken 820 times.
4100 for (int i = 0; i < 4; i++)
22087 3280 skipping_any |= skip_flags[i] ? true : false;
22088
22089 820 bool do_clear_scripts = !get_bit(skip_flags,skip_ffscript);
22090
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
22091 {
22092 set_bit(skip_flags, skip_ffscript, 1);
22093 setZScriptVersion(V_FFSCRIPT);
22094 FFCore.quest_format[vFFScript] = V_FFSCRIPT;
22095 FFCore.quest_format[vLastCompile] = V_FFSCRIPT;
22096 do_clear_scripts = true;
22097 }
22098
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(loading_tileset_flags & TILESET_CLEARMAPS)
22099 {
22100 set_bit(skip_flags, skip_maps, 1);
22101 }
22102
22103 char tmpfilename[L_tmpnam];
22104 820 temp_name(tmpfilename);
22105 820 bool catchup=false;
22106 byte tempbyte;
22107
22108 // oldquest flag is set when an unencrypted qst file is suspected.
22109 820 bool oldquest = false;
22110 820 int32_t open_error=0;
22111 820 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
22112
22113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 820 times.
820 if (!f)
22114 {
22115 ASSERT(open_error != 0);
22116 return open_error;
22117 }
22118
22119 820 memset(quest_rules, 0, QUESTRULES_NEW_SIZE);
22120 820 memset(extra_rules, 0, EXTRARULES_SIZE);
22121 820 unpack_qrs();
22122
22123
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 490 times.
820 if (!get_bit(skip_flags, skip_maps))
22124 490 Regions = {};
22125
22126
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 490 times.
820 if(do_clear_scripts)
22127 {
22128 490 zScript.clear();
22129 490 globalmap.clear();
22130 490 genericmap.clear();
22131 490 ffcmap.clear();
22132 490 itemmap.clear();
22133 490 npcmap.clear();
22134 490 ewpnmap.clear();
22135 490 lwpnmap.clear();
22136 490 playermap.clear();
22137 490 dmapmap.clear();
22138 490 screenmap.clear();
22139 490 itemspritemap.clear();
22140 490 comboscriptmap.clear();
22141 490 subscreenmap.clear();
22142
22143
2/2
✓ Branch 0 taken 250390 times.
✓ Branch 1 taken 490 times.
250880 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
22144 {
22145 250390 ffcmap[i].clear();
22146 250390 }
22147
22148 490 globalmap[0].slotname = "Slot 1:";
22149 490 globalmap[0].scriptname = "~Init";
22150 490 globalmap[0].update();
22151
22152
2/2
✓ Branch 0 taken 3430 times.
✓ Branch 1 taken 490 times.
3920 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
22153 {
22154 3430 globalmap[i].clear();
22155 3430 }
22156
22157
2/2
✓ Branch 0 taken 124950 times.
✓ Branch 1 taken 490 times.
125440 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
22158 {
22159 124950 itemmap[i].clear();
22160 124950 }
22161
22162 //new script types -- prevent carrying over to a quest that you load after reading them
22163 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
22164
2/2
✓ Branch 0 taken 124950 times.
✓ Branch 1 taken 490 times.
125440 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
22165 {
22166 124950 npcmap[i].clear();
22167 124950 }
22168
2/2
✓ Branch 0 taken 124950 times.
✓ Branch 1 taken 490 times.
125440 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
22169 {
22170 124950 lwpnmap[i].clear();
22171 124950 }
22172
2/2
✓ Branch 0 taken 124950 times.
✓ Branch 1 taken 490 times.
125440 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
22173 {
22174 124950 ewpnmap[i].clear();
22175 124950 }
22176
2/2
✓ Branch 0 taken 1960 times.
✓ Branch 1 taken 490 times.
2450 for(int32_t i=0; i<NUMSCRIPTHERO-1; i++)
22177 {
22178 1960 playermap[i].clear();
22179 1960 }
22180
2/2
✓ Branch 0 taken 124950 times.
✓ Branch 1 taken 490 times.
125440 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
22181 {
22182 124950 dmapmap[i].clear();
22183 124950 }
22184
2/2
✓ Branch 0 taken 124950 times.
✓ Branch 1 taken 490 times.
125440 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
22185 {
22186 124950 screenmap[i].clear();
22187 124950 }
22188
2/2
✓ Branch 0 taken 124950 times.
✓ Branch 1 taken 490 times.
125440 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
22189 {
22190 124950 itemspritemap[i].clear();
22191 124950 }
22192
2/2
✓ Branch 0 taken 250390 times.
✓ Branch 1 taken 490 times.
250880 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
22193 {
22194 250390 comboscriptmap[i].clear();
22195 250390 }
22196
2/2
✓ Branch 0 taken 250390 times.
✓ Branch 1 taken 490 times.
250880 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
22197 {
22198 250390 genericmap[i].clear();
22199 250390 }
22200
2/2
✓ Branch 0 taken 124950 times.
✓ Branch 1 taken 490 times.
125440 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
22201 {
22202 124950 subscreenmap[i].clear();
22203 124950 }
22204
22205 490 reset_scripts();
22206 490 }
22207
22208 820 zquestheader tempheader{};
22209
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 tempheader.filename = filename;
22210
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 zinfo tempzi;
22211
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 tempzi.clear();
22212 820 load_tmp_zi = &tempzi;
22213
22214 char zinfofilename[2048];
22215
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 replace_extension(zinfofilename, filename, "zinfo", 2047);
22216 820 int32_t ret=0;
22217
22218 //header
22219
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 box_out("Reading Header...");
22220
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 ret=readheader(f, &tempheader, printmetadata);
22221
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 820 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
820 checkstatus(ret);
22222
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 box_out("okay.");
22223
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 box_eol();
22224
22225
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 612 times.
820 if(read_zinfo)
22226 {
22227
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 box_out("Reading ZInfo - ");
22228
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 205 times.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
208 box_out(read_ext_zinfo ? "External..." : "Internal...");
22229
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 205 times.
208 if(read_ext_zinfo)
22230 {
22231
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
22232
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 ret=readzinfo(inf, tempzi, tempheader);
22233
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(inf) pack_fclose(inf);
22234
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
3 checkstatus(ret);
22235 3 }
22236 else
22237 {
22238
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 ret=readzinfo(f, tempzi, tempheader);
22239
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
205 checkstatus(ret);
22240 }
22241
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 box_out("okay.");
22242
1/2
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
208 box_eol();
22243 208 }
22244
22245
2/2
✓ Branch 0 taken 796 times.
✓ Branch 1 taken 24 times.
820 if(tempheader.zelda_version>=0x193)
22246 {
22247 dword section_id;
22248
22249 //section id
22250
2/4
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 796 times.
✗ Branch 3 not taken.
796 if(!p_mgetl(&section_id,f))
22251 {
22252 goto invalid;
22253 }
22254
22255 796 std::set<dword> seen_sections;
22256
22257
3/4
✓ Branch 0 taken 19369 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18573 times.
✓ Branch 3 taken 796 times.
19369 while(!pack_feof(f))
22258 {
22259
2/4
✓ Branch 0 taken 18573 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18573 times.
✗ Branch 3 not taken.
18573 if (seen_sections.contains(section_id))
22260 goto invalid;
22261
1/2
✓ Branch 0 taken 18573 times.
✗ Branch 1 not taken.
18573 seen_sections.insert(section_id);
22262
22263
3/4
✓ Branch 0 taken 18573 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11664 times.
✓ Branch 3 taken 6909 times.
18573 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22264 {
22265
1/2
✓ Branch 0 taken 6909 times.
✗ Branch 1 not taken.
6909 if (retval == qe_cancel)
22266 6909 continue;
22267 checkstatus(retval);
22268 }
22269
22270
24/25
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 467 times.
✓ Branch 2 taken 796 times.
✓ Branch 3 taken 796 times.
✓ Branch 4 taken 467 times.
✓ Branch 5 taken 408 times.
✓ Branch 6 taken 796 times.
✓ Branch 7 taken 467 times.
✓ Branch 8 taken 467 times.
✓ Branch 9 taken 467 times.
✓ Branch 10 taken 467 times.
✓ Branch 11 taken 467 times.
✓ Branch 12 taken 408 times.
✓ Branch 13 taken 408 times.
✓ Branch 14 taken 467 times.
✓ Branch 15 taken 467 times.
✓ Branch 16 taken 408 times.
✓ Branch 17 taken 408 times.
✓ Branch 18 taken 408 times.
✓ Branch 19 taken 408 times.
✓ Branch 20 taken 467 times.
✓ Branch 21 taken 467 times.
✓ Branch 22 taken 408 times.
✓ Branch 23 taken 408 times.
✗ Branch 24 not taken.
11664 switch(section_id)
22271 {
22272 case ID_RULES:
22273
22274 //rules
22275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if(catchup)
22276 {
22277 box_out("found.");
22278 box_eol();
22279 catchup=false;
22280 }
22281
22282
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("Reading Rules...");
22283
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 ret=readrules(f, &tempheader);
22284
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
467 checkstatus(ret);
22285
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("okay.");
22286
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_eol();
22287 467 break;
22288
22289 case ID_STRINGS:
22290
22291 //strings
22292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if(catchup)
22293 {
22294 box_out("found.");
22295 box_eol();
22296 catchup=false;
22297 }
22298
22299
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("Reading Strings...");
22300
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 ret=readstrings(f, &tempheader);
22301
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
467 checkstatus(ret);
22302
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("okay.");
22303
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_eol();
22304 467 break;
22305
22306 case ID_MISC:
22307
22308 //misc data
22309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 796 times.
796 if(catchup)
22310 {
22311 box_out("found.");
22312 box_eol();
22313 catchup=false;
22314 }
22315
22316
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 box_out("Reading Misc. Data...");
22317
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 ret=readmisc(f, &tempheader, Misc);
22318
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 796 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
796 checkstatus(ret);
22319
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 box_out("okay.");
22320
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 box_eol();
22321 796 break;
22322
22323 case ID_TILES:
22324
22325 //tiles
22326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 796 times.
796 if(catchup)
22327 {
22328 box_out("found.");
22329 box_eol();
22330 catchup=false;
22331 }
22332
22333
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 box_out("Reading Tiles...");
22334
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
22335
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 796 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
796 checkstatus(ret);
22336
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 box_out("okay.");
22337
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 box_eol();
22338 796 break;
22339
22340 case ID_COMBOS:
22341
22342 //combos
22343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if(catchup)
22344 {
22345 box_out("found.");
22346 box_eol();
22347 catchup=false;
22348 }
22349
22350
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("Reading Combos...");
22351
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
22352 467 combosread=true;
22353
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
467 checkstatus(ret);
22354
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("okay.");
22355
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_eol();
22356 467 break;
22357
22358 case ID_COMBOALIASES:
22359
22360 //combo aliases
22361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(catchup)
22362 {
22363 box_out("found.");
22364 box_eol();
22365 catchup=false;
22366 }
22367
22368
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_out("Reading Combo Aliases...");
22369
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
22370
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
408 checkstatus(ret);
22371
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_out("okay.");
22372
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_eol();
22373 408 break;
22374
22375 case ID_CSETS:
22376
22377 //color data
22378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 796 times.
796 if(catchup)
22379 {
22380 box_out("found.");
22381 box_eol();
22382 catchup=false;
22383 }
22384
22385
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 box_out("Reading Color Data...");
22386
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
22387
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 796 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
796 checkstatus(ret);
22388
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 box_out("okay.");
22389
1/2
✓ Branch 0 taken 796 times.
✗ Branch 1 not taken.
796 box_eol();
22390 796 break;
22391
22392 case ID_MAPS:
22393
22394 //maps
22395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if(catchup)
22396 {
22397 box_out("found.");
22398 box_eol();
22399 catchup=false;
22400 }
22401
22402
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("Reading Maps...");
22403
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 ret=readmaps(f, &tempheader);
22404 467 mapsread=true;
22405
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
467 checkstatus(ret);
22406
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("okay.");
22407
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_eol();
22408 467 break;
22409
22410 case ID_DMAPS:
22411
22412 //dmaps
22413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if(catchup)
22414 {
22415 box_out("found.");
22416 box_eol();
22417 catchup=false;
22418 }
22419
22420
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("Reading DMaps...");
22421
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
22422
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
467 checkstatus(ret);
22423
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("okay.");
22424
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_eol();
22425 467 break;
22426
22427 case ID_DOORS:
22428
22429 //door combo sets
22430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if(catchup)
22431 {
22432 box_out("found.");
22433 box_eol();
22434 catchup=false;
22435 }
22436
22437
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("Reading Doors...");
22438
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 ret=readdoorcombosets(f, &tempheader);
22439
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
467 checkstatus(ret);
22440
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("okay.");
22441
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_eol();
22442 467 break;
22443
22444 case ID_ITEMS:
22445
22446 //items
22447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if(catchup)
22448 {
22449 box_out("found.");
22450 box_eol();
22451 catchup=false;
22452 }
22453
22454
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("Reading Items...");
22455
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 ret=readitems(f, tempheader.zelda_version, tempheader.build);
22456
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
467 checkstatus(ret);
22457
22458
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("okay.");
22459
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_eol();
22460 467 break;
22461
22462 case ID_WEAPONS:
22463
22464 //weapons
22465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if(catchup)
22466 {
22467 box_out("found.");
22468 box_eol();
22469 catchup=false;
22470 }
22471
22472
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("Reading Weapons...");
22473
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 ret=readweapons(f, &tempheader);
22474
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
467 checkstatus(ret);
22475
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("okay.");
22476
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_eol();
22477 467 break;
22478
22479 case ID_COLORS:
22480
22481 //misc. colors
22482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(catchup)
22483 {
22484 box_out("found.");
22485 box_eol();
22486 catchup=false;
22487 }
22488
22489
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_out("Reading Misc. Colors...");
22490
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 ret=readmisccolors(f, &tempheader, Misc);
22491
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
408 checkstatus(ret);
22492
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_out("okay.");
22493
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_eol();
22494 408 break;
22495
22496 case ID_ICONS:
22497
22498 //game icons
22499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(catchup)
22500 {
22501 box_out("found.");
22502 box_eol();
22503 catchup=false;
22504 }
22505
22506
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_out("Reading Game Icons...");
22507
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 ret=readgameicons(f, &tempheader, Misc);
22508
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
408 checkstatus(ret);
22509
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_out("okay.");
22510
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_eol();
22511 408 break;
22512
22513 case ID_INITDATA:
22514
22515 //initialization data
22516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if(catchup)
22517 {
22518 box_out("found.");
22519 box_eol();
22520 catchup=false;
22521 }
22522
22523
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("Reading Init. Data...");
22524
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 ret=readinitdata(f, &tempheader);
22525
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
467 checkstatus(ret);
22526
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("okay.");
22527
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_eol();
22528
22529
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 467 times.
467 if(!get_bit(skip_flags, skip_subscreens))
22530 {
22531
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 373 times.
467 if(subscr_mode!=ssdtMAX) //not using custom subscreens
22532 {
22533
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 setupsubscreens();
22534
22535
2/2
✓ Branch 0 taken 48128 times.
✓ Branch 1 taken 94 times.
48222 for(int32_t i=0; i<MAXDMAPS; ++i)
22536 {
22537 48128 int32_t type=DMaps[i].type&dmfTYPE;
22538
2/2
✓ Branch 0 taken 1086 times.
✓ Branch 1 taken 47042 times.
48128 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22539 48128 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22540 48128 }
22541 94 }
22542 467 }
22543
22544
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
467 if(!get_bit(skip_flags, skip_sfx))
22545 {
22546 467 setupsfx();
22547 467 }
22548
22549
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 467 times.
✗ Branch 3 not taken.
467 if(!get_bit(skip_flags, skip_itemdropsets))
22550 {
22551
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 init_item_drop_sets();
22552 467 }
22553
22554
2/4
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 467 times.
467 if(!get_bit(skip_flags, skip_favorites))
22555 {
22556 467 init_favorites();
22557 467 }
22558
22559 467 break;
22560
22561 case ID_GUYS:
22562
22563 //guys
22564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if(catchup)
22565 {
22566 box_out("found.");
22567 box_eol();
22568 catchup=false;
22569 }
22570
22571
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("Reading Custom Guy Data...");
22572
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 ret=readguys(f, &tempheader);
22573
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
467 checkstatus(ret);
22574
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("okay.");
22575
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_eol();
22576 467 break;
22577
22578 case ID_HEROSPRITES:
22579
22580 //hero sprites
22581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(catchup)
22582 {
22583 box_out("found.");
22584 box_eol();
22585 catchup=false;
22586 }
22587
22588
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_out("Reading Custom Hero Sprite Data...");
22589
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 ret=readherosprites(f, &tempheader);
22590
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
408 checkstatus(ret);
22591
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_out("okay.");
22592
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_eol();
22593 408 break;
22594
22595 case ID_SUBSCREEN:
22596
22597 //custom subscreens
22598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(catchup)
22599 {
22600 box_out("found.");
22601 box_eol();
22602 catchup=false;
22603 }
22604
22605
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_out("Reading Custom Subscreen Data...");
22606
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 ret=readsubscreens(f);
22607
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
408 checkstatus(ret);
22608
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_out("okay.");
22609
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_eol();
22610 408 break;
22611
22612 case ID_FFSCRIPT:
22613
22614 //Freeform combo scripts
22615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(catchup)
22616 {
22617 box_out("found.");
22618 box_eol();
22619 catchup=false;
22620 }
22621
22622
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_out("Reading FF Script Data...");
22623
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 ret=readffscript(f, &tempheader);
22624
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
408 checkstatus(ret);
22625
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_out("okay.");
22626
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_eol();
22627 408 break;
22628
22629 case ID_SFX:
22630
22631 //SFX data
22632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(catchup)
22633 {
22634 box_out("found.");
22635 box_eol();
22636 catchup=false;
22637 }
22638
22639
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_out("Reading SFX Data...");
22640
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 ret=readsfx(f, &tempheader);
22641
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
408 checkstatus(ret);
22642
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_out("okay.");
22643
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_eol();
22644 408 break;
22645
22646 case ID_MIDIS:
22647
22648 //midis
22649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if(catchup)
22650 {
22651 box_out("found.");
22652 box_eol();
22653 catchup=false;
22654 }
22655
22656
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("Reading MIDIs...");
22657
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 ret=readmidis(f, &tempheader, tunes);
22658
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
467 checkstatus(ret);
22659
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("okay.");
22660
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_eol();
22661 467 break;
22662
22663 case ID_CHEATS:
22664
22665 //cheat codes
22666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
467 if(catchup)
22667 {
22668 box_out("found.");
22669 box_eol();
22670 catchup=false;
22671 }
22672
22673
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("Reading Cheat Codes...");
22674
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 ret=readcheatcodes(f, &tempheader);
22675
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
467 checkstatus(ret);
22676
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_out("okay.");
22677
1/2
✓ Branch 0 taken 467 times.
✗ Branch 1 not taken.
467 box_eol();
22678 467 break;
22679
22680 case ID_ITEMDROPSETS:
22681
22682 //item drop sets
22683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(catchup)
22684 {
22685 box_out("found.");
22686 box_eol();
22687 catchup=false;
22688 }
22689
22690
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_out("Reading Item Drop Sets...");
22691
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 ret=readitemdropsets(f, tempheader.zelda_version);
22692
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
408 checkstatus(ret);
22693
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_out("okay.");
22694
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_eol();
22695 408 break;
22696
22697 case ID_FAVORITES:
22698
22699 //favorite combos and combo aliases
22700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
408 if(catchup)
22701 {
22702 box_out("found.");
22703 box_eol();
22704 catchup=false;
22705 }
22706
22707
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_out("Reading Favorite Combos...");
22708
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 ret=readfavorites(f, tempheader.zelda_version);
22709
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
408 checkstatus(ret);
22710
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_out("okay.");
22711
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 box_eol();
22712 408 break;
22713
22714 default:
22715 if(!catchup)
22716 {
22717 box_out("Bad token! Searching...");
22718 box_eol();
22719 }
22720
22721 catchup=true;
22722 break;
22723 }
22724
22725
22726
1/2
✓ Branch 0 taken 11664 times.
✗ Branch 1 not taken.
11664 if(catchup)
22727 {
22728 //section id
22729 section_id=(section_id<<8);
22730
22731 if(!p_getc(&tempbyte,f))
22732 {
22733 goto invalid;
22734 }
22735
22736 section_id+=tempbyte;
22737 }
22738
22739 else
22740 {
22741 //section id
22742
3/4
✓ Branch 0 taken 11664 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11197 times.
✓ Branch 3 taken 467 times.
11664 if(!pack_feof(f))
22743 {
22744
2/4
✓ Branch 0 taken 11197 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11197 times.
✗ Branch 3 not taken.
11197 if(!p_mgetl(&section_id,f))
22745 {
22746 goto invalid;
22747 }
22748 11197 }
22749 }
22750 }
22751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 796 times.
796 }
22752 else
22753 {
22754
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22755
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22756
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22757
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22758
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22759
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22760
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22761
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22762
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22763
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22764
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22765
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22766
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22767
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "MIDIs", ID_MIDIS, [&](){ return readmidis(f, &tempheader, tunes); }},
22768
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22769
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22770
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Hero Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1); }},
22771
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1); }},
22772 };
22773
22774 24 legacy_skip_flags = skip_flags;
22775
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 408 times.
1250 for (auto& [desc, section_id, fn] : hardcoded_sections)
22776 {
22777
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 int section_enum = section_id_to_enum(section_id);
22778
2/4
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 408 times.
✗ Branch 3 not taken.
408 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
22779
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 16 times.
408 if (skip)
22780 {
22781 // Nothing to read.
22782
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 15 times.
16 if (section_id == ID_RULES)
22783 1 continue;
22784
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14 times.
15 if (section_id == ID_GUYS)
22785 1 continue;
22786
22787 // Haven't looked at how to skip these, because we don't need to currently: the only
22788 // usage of skip_flags currently is all off except: header and tiles (see `load_imagebuf`).
22789
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (section_id == ID_MIDIS)
22790 1 continue;
22791
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
13 if (section_id == ID_CHEATS)
22792 1 continue;
22793
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11 times.
12 if (section_id == ID_INITDATA)
22794 1 continue;
22795
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if (section_id == ID_HEROSPRITES)
22796 1 continue;
22797
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
10 if (section_id == ID_ITEMDROPSETS)
22798 1 continue;
22799 9 }
22800
22801 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22802 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22803 // read all the sections even if requested to skip some.
22804 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22805 // {
22806 // if (retval == qe_cancel)
22807 // continue;
22808 // checkstatus(retval);
22809 // }
22810
22811
3/6
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 401 times.
✗ Branch 5 not taken.
802 box_out(fmt::format("Reading {}...", desc).c_str());
22812
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 ret = fn();
22813
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 401 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
401 checkstatus(ret);
22814
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_out("okay.");
22815
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_eol();
22816 }
22817 24 legacy_skip_flags = nullptr;
22818
22819
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_subscreens))
22820 {
22821
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 setupsubscreens();
22822
22823
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 23 times.
11799 for(int32_t i=0; i<MAXDMAPS; ++i)
22824 {
22825 11776 int32_t type=DMaps[i].type&dmfTYPE;
22826
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11732 times.
11776 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22827 11776 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22828 11776 }
22829 23 }
22830
22831
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("Setting Up Default Sound Effects...");
22832
22833
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 23 times.
24 if(!get_bit(skip_flags, skip_sfx))
22834 23 setupsfx();
22835
22836
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_favorites))
22837 23 init_favorites();
22838
22839
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("okay.");
22840
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_eol();
22841
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
24 }
22842
22843
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 init_spritelists();
22844
22845 // check data
22846
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(f)
22847 {
22848
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 pack_fclose(f);
22849 820 }
22850
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 clear_quest_tmpfile();
22851
22852
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(!oldquest)
22853 {
22854
2/4
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 820 times.
820 if(exists(tmpfilename))
22855 {
22856 delete_file(tmpfilename);
22857 }
22858 820 }
22859
22860
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 820 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
820 if(fixffcs && combosread && mapsread)
22861 {
22862 for(int32_t i=0; i<map_count; i++)
22863 {
22864 for(int32_t j=0; j<MAPSCRS; j++)
22865 {
22866 int c = TheMaps[(i*MAPSCRS)+j].numFFC();
22867 for(int32_t m=0; m<c; m++)
22868 {
22869 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].data].type == cCHANGE)
22870 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffc_changer;
22871 }
22872 }
22873 }
22874 }
22875
22876
3/4
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 490 times.
✓ Branch 3 taken 330 times.
820 if (!get_bit(skip_flags, skip_rules))
22877 {
22878
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 bool should_hide = compat_qr_hide_bottom_pixels(tempheader);
22879
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 al_trace("Note: qr_HIDE_BOTTOM_8_PIXELS %s via compat rule\n", should_hide ? "enabled" : "disabled");
22880
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 416 times.
490 if (should_hide)
22881
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 set_qr(qr_HIDE_BOTTOM_8_PIXELS, 1);
22882
22883
3/4
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 163 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 327 times.
490 if (FFCore.quest_format[vCompatRule] < 77 && Header->is_z3)
22884 set_qr(qr_LAYER6_STRINGS_OVER_SUBSCREEN, 1);
22885 490 }
22886
22887
7/10
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 757 times.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 62 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 62 times.
✗ Branch 9 not taken.
820 if(get_qr(qr_CONTFULL_DEP) && !get_bit(skip_flags, skip_rules) && !get_bit(skip_flags, skip_initdata))
22888 {
22889
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 set_qr(qr_CONTFULL_DEP, 0);
22890
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 zinit.flags.set(INIT_FL_CONTPERCENT,true);
22891 62 zinit.cont_heart=100;
22892 62 zinit.counter[crLIFE]=zinit.mcounter[crLIFE];
22893 62 }
22894
22895
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 box_out("Done.");
22896
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 box_eol();
22897
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 box_end(false);
22898
22899
3/4
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 491 times.
✓ Branch 3 taken 329 times.
820 if(!get_bit(skip_flags, skip_header))
22900 {
22901
1/2
✓ Branch 0 taken 491 times.
✗ Branch 1 not taken.
491 *Header = tempheader;
22902 491 }
22903
3/4
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 490 times.
✓ Branch 3 taken 330 times.
820 if(!get_bit(skip_flags, skip_zinfo))
22904 {
22905
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 ZI.copyFrom(tempzi);
22906 490 }
22907
22908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 820 times.
820 if(loading_tileset_flags & TILESET_CLEARMAPS)
22909 {
22910 TheMaps.clear();
22911 TheMaps.resize(MAPSCRS*1);
22912 map_count = 1;
22913 map_infos.clear();
22914 map_infos.resize(1);
22915 }
22916
22917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 820 times.
820 if(loading_tileset_flags & TILESET_CLEARHEADER)
22918 {
22919 memset(Header->password, 0, sizeof(Header->password));
22920 memset(Header->minver, 0, sizeof(Header->minver));
22921 memset(Header->title, 0, sizeof(Header->title));
22922 memset(Header->author, 0, sizeof(Header->author));
22923 memset(Header->version, 0, sizeof(Header->version));
22924 Header->use_keyfile = 0;
22925 Header->dirty_password = false;
22926 cvs_MD5Context ctx;
22927 cvs_MD5Init(&ctx);
22928 cvs_MD5Update(&ctx, (const uint8_t*)"", 0);
22929 cvs_MD5Final(Header->pwd_hash, &ctx);
22930 }
22931
22932
3/4
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 490 times.
✓ Branch 3 taken 330 times.
820 if (!get_bit(skip_flags, skip_maps))
22933 {
22934 // Not needed, so release its memory.
22935
1/2
✓ Branch 0 taken 490 times.
✗ Branch 1 not taken.
490 old_combo_pages = {};
22936 490 }
22937
22938
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 490 times.
820 if (skipping_any)
22939
1/2
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
330 restore_prev_qstload_global_state();
22940
22941 820 return qe_OK;
22942
22943 invalid:
22944 // TODO: It's too easy to forget to jump to this label, and accidentally leave the file open.
22945 // Should wrap PACKFILE in a std::unique_pointer with a custom deallocator.
22946 box_out("error.");
22947 box_eol();
22948 box_end(true);
22949
22950 pack_fclose(f);
22951
22952 if(!oldquest)
22953 {
22954 if(exists(tmpfilename))
22955 {
22956 delete_file(tmpfilename);
22957 }
22958 }
22959
22960 restore_prev_qstload_global_state();
22961
22962 return qe_invalid;
22963
22964 820 }
22965
22966 static bool _is_loading_quest;
22967
22968 bool is_loading_quest()
22969 {
22970 return _is_loading_quest;
22971 }
22972
22973 329 std::string get_last_loaded_qstpath()
22974 {
22975 329 return last_loaded_qstpath;
22976 }
22977
22978 820 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc,
22979 zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata,
22980 bool report, byte qst_num, dword tilesetflags)
22981 {
22982 820 loading_tileset_flags = tilesetflags;
22983 820 const char* basename = get_filename(filename);
22984 820 zapp_reporting_add_breadcrumb("load_quest", basename);
22985 820 zapp_reporting_set_tag("qst.filename", basename);
22986
22987 820 last_loaded_qstpath = filename;
22988 820 loading_qst_name = filename;
22989 820 loading_qst_num = qst_num;
22990 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22991 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22992
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if (!is_ci())
22993 loadquest_report = report;
22994
22995 820 _is_loading_quest = true;
22996 820 auto start = std::chrono::steady_clock::now();
22997 820 zprint2("Loading qst: %s\n", filename);
22998 820 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22999 820 int32_t load_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();
23000 820 zprint2("Time to load qst: %d ms\n", load_ms);
23001 820 _is_loading_quest = false;
23002
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if (ret)
23003 zprint2("Error: %s\n", qst_error[ret]);
23004
23005
1/2
✓ Branch 0 taken 820 times.
✗ Branch 1 not taken.
820 if(show_progress)
23006 {
23007 if(ret)
23008 {
23009 box_out("-- Error loading quest file! --");
23010 box_out(fmt::format("Error: {}", qst_error[ret]).c_str());
23011 box_end(true);
23012 }
23013 else box_end(false);
23014 }
23015
23016 820 load_tmp_zi = NULL;
23017 820 loading_qst_name = NULL;
23018 820 loadquest_report = false;
23019 820 loading_qst_num = 0;
23020
23021 820 zapp_reporting_set_tag("qst.author", Header->author);
23022 820 zapp_reporting_set_tag("qst.title", Header->title);
23023 820 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
23024
23025 820 return ret;
23026 }
23027